Overlays

Overlays are objects on the map that are bound to latitude/longitude coordinates or dimensions. The array of overlay instances are binding through the overlays property. Due to the nature of one-way binding, when there are changes from an array then the map will update automatically.

GMap supports various types of overlays, as shown here:

  • Marker: Single locations on a map. Markers can also display custom icon images.
  • Polyline: Series of straight lines on a map.
  • Polygon: Series of straight lines on a map but the shape is "closed."
  • Circle and rectangle: Represents a specific region as a circle/rectangle.
  • Info windows: Displays content within a pop-up balloon on top of a map.

The GMap example usage with overlay options would be written as follows:

<p-gmap [options]="options" [overlays]="overlays"  
[styleClass]="'dimensions'"></p-gmap>

Let's define an array of overlay instances such as markers, polyline, polygon, circle, and so on, as shown here:

this.overlays = [
new google.maps.Marker({position: {lat: 14.6188043,
lng: 79.9630253}, title:"Talamanchi"}),
new google.maps.Marker({position: {lat: 14.4290442,
ng: 79.9456852}, title:"Nellore"}),
new google.maps.Polygon({paths: [
{lat: 14.1413809, lng: 79.8254154}, {lat: 11.1513809,
lng: 78.8354154},
{lat: 15.1313809, lng: 78.8254154},{lat: 15.1613809,
lng: 79.8854154}
], strokeOpacity: 0.5, strokeWeight: 1,
fillColor: '#1976D2', fillOpacity: 0.35
}),
new google.maps.Circle({center: {lat: 14.1413809, lng: 79.9513809},
fillColor: '#197642', fillOpacity: 0.25, strokeWeight: 1,
radius: 25000}), new google.maps.Polyline({path: [{lat: 14.1413809,
lng: 79.9254154}, {lat: 14.6413809, lng: 79.9254154}],
geodesic: true, strokeColor: '#F0F000', strokeOpacity: 0.5,
strokeWeight: 2})
];

The following screenshot shows a snapshot result of the GMap with various overlays as an example:

In the preceding map, you can observe that markers, a polygon, and a circle are displayed based on the co-ordinates provided and also based on other overlay-specific configurations.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.200.109