How to create multiple polylines

3,725 views
Skip to first unread message

Amanuel Medhanie

unread,
Jun 8, 2011, 1:21:43 AM6/8/11
to google-map...@googlegroups.com
Hello everyone.  Any help on this would be appreciated.  I've used the example code for creating polylines found here: http://code.google.com/apis/maps/documentation/javascript/overlays.html#Polylines

The section of code that specified the different polylines is as follows:

var flightPlanCoordinates = [
   
new google.maps.LatLng(37.772323, -122.214897),
   
new google.maps.LatLng(21.291982, -157.821856),
   
new google.maps.LatLng(-18.142599, 178.431),
   
new google.maps.LatLng(-27.46758, 153.027892)
 
];
 
var flightPath = new google.maps.Polyline({
    path
: flightPlanCoordinates,
    strokeColor
: "#FF0000",
    strokeOpacity
: 1.0,
    strokeWeight
: 2



However, I would like to specify several polylines without having to repeatedly write these two "chunks" of code for each polyline. Any ideas? Thanks!

geoco...@gmail.com

unread,
Jun 8, 2011, 1:36:57 AM6/8/11
to Google Maps JavaScript API v3
On Jun 7, 10:21 pm, Amanuel Medhanie <medha...@gmail.com> wrote:
> Hello everyone.  Any help on this would be appreciated.  I've used the
> example code for creating polylines found here:http://code.google.com/apis/maps/documentation/javascript/overlays.ht...
>
> The section of code that specified the different polylines is as follows:
>
> var flightPlanCoordinates = [
>     new google.maps.LatLng(37.772323, -122.214897),
>     new google.maps.LatLng(21.291982, -157.821856),
>     new google.maps.LatLng(-18.142599, 178.431),
>     new google.maps.LatLng(-27.46758, 153.027892)
>   ];
>   var flightPath = new google.maps.Polyline({
>     path: flightPlanCoordinates,
>     strokeColor: "#FF0000",
>     strokeOpacity: 1.0,
>     strokeWeight: 2
>
> However, I would like to specify several polylines without having to repeatedly write these two "chunks" of code for each polyline.  Any ideas?  Thanks!

You mean something like this?
http://www.geocodezip.com/v3_GenericMapBrowser.asp?filename=flights090427.xml
(the polylines are create from xml, but you don't need to do that)

-- Larry
Reply all
Reply to author
Forward
0 new messages