First you need to ind out how much a pixel is worth in degrees of Lat/ Lon at the current zoom and at the relevant location. Once you know that, you can use that information to set the width of your polyline in meters.
//NOT TESTED! var lineWidth = 25; //miles var proj = map.getCurrentMapType().getProjection() var centerPx = proj.fromLatLngToPixel(center, zoom); var neightbourLatLon = proj.fromPixelToLatLng(new GPoint(centerPx.x +1,centerPx.y), zoom); //divide by 1609 to get miles. If you want meters don't divide. var dPx = neightbourLatLon.distanceFrom(center) / 1609.344; var pxWidth = Math.ceil(lineWidth / dPx) * 2; var poly = new GPolyline(pLinePoints,'#FFFF00',pxWidth, 0.30); map.addOverlay(poly); I'm using a similar approach here: http://maps.forum.nu/gm_texas.html ... but the code is a little messy. :-) -- Marcelo - http://maps.forum.nu -- On Aug 13, 6:47 pm, Patrice <[email protected]> wrote: > Hi everybody ! > > I'm French so sorry for my English mistakes. > > I can't find the solution to my problem anywhere ! You all know that > we can set the width of a polyline thanks to the option "weight". But > the value has to be in pixels. > > I would like to know how I can do to set the width of my polyline to x > meters (x=20 for instance). In other words, how do you convert meters > to pixels, according to the zoom level ? > > Thank you for your help ! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
