Hi, When we vreate an array like this, how to use it in Gpolygon? Should we directly put the array into the GPolygon() ? Thanks
On 30 Temmuz, 15:20, Andrew Leach <[email protected]> wrote: > On Jul 30, 12:38 pm, amigoface <[email protected]> wrote: > > > hi i have and array of string in this form > > > the problem is that i don't know how to add the points to the polyline > > constructor > > The thing here is to begin programming with what you want to end up > with, and work backwards so that your data can be used. You need to > use the documentation. What you shouldn't do is make assumptions about > how to do > something.http://code.google.com/apis/maps/documentation/reference.html#GPolyli... > > map.addOverlay(polyline); > > Fine: how is a polyline defined? > > var polyline = new GPolyline(array); > > It uses an array of GLatLngs. There are some other parameters too, but > they're not part of the "how to use my data" process. > > So you need to create an array of GLatLng() objects and then use that > for your line. You have an array of your own, so use that to create an > array of GLatLngs: > > var array = new Array(); > for (i=0 ; i<trajetarray; i++) > { > s = trajetarray[i]; > var exp=explode(";", s); > longitude = exp[0]; > longitude = exp[1]; > longitude = exp[2]; > // presumably you don't really use three longitude > // assignments like this? Anyway, you don't need it: > array.push(new GLatLng(exp[1],exp[0])); > } > > You may need to use parseFloat() on your exploded values, if they are > strings. > > Andrew --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Maps-API?hl=en -~----------~----~----~----~------~----~------~--~---
