Actually Mike, I don't think that's right. My original code *did* mimic the OL code, and didn't work. I'm not entirely clear why, otherwise I wouldn't've needed to post here. However, I suspect the reason it works in OL and not in Google concerns projections, and the differences in between those used.
Natively OL uses EPSG:4326, http://spatialreference.org/ref/epsg/4326, whereas Google is EPSG:900913, http://spatialreference.org/ref/sr-org/6627, a spherical mercator. Hence OL maps require tweaks when loading Google layers, http://faq.openlayers.org/vector-related-questions/why-dont-my-vector-features-work-over-google-yahoo-virtual-earth-etc, which, if you omit, strange things start happening, such as the marker shying away from the edges of the map as you drag the map, and so on. You can spot these tweaks if you examine the source code of the working OL example linked above: GoogleMap = new OpenLayers.Map ( aMapDiv, { ... projection: EPSG900913, units: "m", maxResolution: 156543.0339, numZoomLevels: 20, maxExtent: new OpenLayers.Bounds( ... ), ... } ); GoogleMap.addLayers ( [ ...( "Google Streets", { ..., 'sphericalMercator':true, ...} ), ...( "Google Satellite", {..., 'sphericalMercator':true, ...} ), ...( "Google Hybrid", { ..., 'sphericalMercator':true, ...} ) ] ); ... var rLonLat = new OpenLayers.LonLat( aLong, aLat ); var rXY = rLonLat.transform( EPSG4326, EPSG900913 ); ... GoogleMarkerF = createDragDirMarker( rXY, anAzim, markerStyle ); Another consequence of Google's projection which implicitly you have already pointed out is that the units of the projection is metres and but their API requires you to specify positions in degrees, with Google doing any necassary internal conversions transparently. This is doubtless fine for many situations. but the transparency makes it more difficult to work out what is going wrong when things don't work, and takes control away from the map developer in those situations where (s)he might need it. This mismatch between the projection and the API explains the need for the correction that I've indicated works for short markers, dividing delta longitude by cos(latitude). On Jun 1, 1:05 pm, Mike Williams <[email protected]> wrote: > I believe that the original OpenLayers code calculated the actual > azimuth as would be observed by someone standing on a spherical earth. > To obtain the same results, you'd need to do the same thing. As I said > originally, that can be achieved either by using the same algorithm as > the .rotate() from OpenLayers, or by using EOffsetBearing(). --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
