[OpenLayers-Dev] Vector layer marker drifting with Google base
map
Eric Lemoine
eric.c2c at gmail.com
Thu Sep 18 01:19:26 EDT 2008
Hi Sean. You need to use ESPG:900913 and set sphericalMercator to true
in the options passed to the constructor of the Google layer. There's
a page on OpenLayers' wiki about this, search SphericalMercator using
the wiki's search engine. Cheers. Eric
2008/9/18, Sean Gillies <sgillies at frii.com>:
> Hi all,
>
> I'm trying to overlay a point vector layer symbolized with drop shadow
> markers over a base Google layer. Things look fine, the marker is where
> I expect it, until I pan and then the position of the marker begins to
> drift approximately half height of the marker in the panning direction.
> I'm using the javascript served from openlayers.org/api/OpenLayers.js.
>
> Known bug? Programmer error? Script below:
>
>
> <script type="text/javascript">
> var map, base, marker, coords;
> var SHADOW_Z_INDEX = 10;
> var MARKER_Z_INDEX = 11;
>
> function init() {
> map = new OpenLayers.Map('map');
> base = new OpenLayers.Layer.Google(
> "Base", {
> isBaseLayer: true,
> type: G_PHYSICAL_MAP,
> }
> );
> marker = new OpenLayers.Layer.Vector(
> "Marker",
> {
> styleMap: new OpenLayers.StyleMap({
> externalGraphic:
> "http://openlayers.org/dev/img/marker-gold.png",
> backgroundGraphic:
> "http://openlayers.org/dev/examples/marker_shadow.png",
> backgroundXOffset: 0,
> backgroundYOffset: -7,
> graphicZIndex: MARKER_Z_INDEX,
> backgroundGraphicZIndex: SHADOW_Z_INDEX,
> pointRadius: 10
> }),
> reproject: true,
> isBaseLayer: false,
> projection
> rendererOptions: {yOrdering: true}
> }
> );
> coords = pleiades_oljs.centroid.coordinates;
> map.addLayers([base, marker]);
> map.setCenter(new OpenLayers.LonLat(coords[0], coords[1]), 5);
> marker.features.push(
> new OpenLayers.Feature.Vector(
> new OpenLayers.Geometry.Point(coords[0], coords[1])
> )
> );
> }
> </script>
>
> I'm grateful for any suggestions.
>
> Sean
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev
>
More information about the Dev
mailing list