A basic polyline in google map
Polylines are used to mark out roads, borders and other things that are made of lines in maps. The Google Maps API offers a class for drawing these lines on a Google Map called GPolyline. In this entry I will show you how to use these and how to deal with potential performance issues when the polylines gets more complex.
// Create an instance of Google map
var map = new GMap2(document.getElementById("map"));
// Tell the map where to start
map.setCenter(new GLatLng(3.965,108.054), 5);
// Create an array with points
var points = [
new GLatLng(0.165,100.044),
new GLatLng(4.365,108.034)
];
// Create a new polyline
var polyline = new GPolyline(points, '#ff0000', 5, 2.7);
// Add the polyline to the map using map.addOverlay()
map.addOverlay(polyline);
[img_assist|nid=868|title=polyline|desc=|link=none|align=left|width=561|height=497]
- tuan.norlida's blog
- Login to post comments
Copyright © 2008-2011