Circle class

April 20, 2018 ยท View on GitHub

This class extends BaseClass.

Contents


Overview

Create one circle

The map.addCircleSync() method adds one circle onto the map.

loadMap() {

  let GOOGLE: ILatLng = {"lat" : 37.422858, "lng" : -122.085065};
  this.map = GoogleMaps.create('map_canvas');

  // Add circle
  let circle: Circle = this.map.addCircleSync({
    'center': GOOGLE,
    'radius': 300,
    'strokeColor' : '#AA00FF',
    'strokeWidth': 5,
    'fillColor' : '#880000'
  });

  this.map.moveCamera({
    target: circle.getBounds()
  });

}

Listen CIRCLE_CLICK event

In order to listen the CIRCLE_CLICK event, you need to specify the clickable option. You can get the latitude/longitude pair of clicked position.

loadMap() {

  // Add a circle
  let circle: Circle = this.map.addCircleSync({
    'center': GOOGLE,
    'radius': 300,
    'strokeColor' : '#AA00FF',
    'strokeWidth': 5,
    'fillColor' : '#880000',
    'clickable' : true   // default = false
  });

  this.map.moveCamera({
    target: circle.getBounds()
  });

  // Catch the CIRCLE_CLICK event
  circle.on(GoogleMapsEvent.CIRCLE_CLICK).subscribe(this.onCircleClick.bind(this));

}

onCircleClick(params: any[]) {
  let latLng: ILatLng = params[0];
  let circle: Circle = params[1];

  ...
}

bindTo() method

The bindTo() method is useful when you manipulate multiple overlays with the same value. The bindTo() method comes from BaseClass.

loadMap() {
  ...

  let marker: Marker = this.map.addMarkerSync({
    position: {lat: 43.0741704, lng: -89.3809802},
    draggable: true
  });

  let circle: Circle = this.map.addCircleSync({
    center: marker.getPosition(),
    radius: 10,
    fillColor: "rgba(0, 0, 255, 0.5)",
    strokeColor: "rgba(0, 0, 255, 0.75)",
    strokeWidth: 1
  });

  // circle.center = marker.position
  marker.bindTo("position", circle, "center");
}

API Reference


Create methods


Instance methods


Event

  • CIRCLE_CLICK :orange_book:

    This event is fired when you click on a circle.

    Params Type Details
    params[0] LatLng clicked position
    params[1] Circle circle instance