[OpenLayers-Users] BING and OpenLayers
Eric Lemoine
eric.lemoine at camptocamp.com
Sat Mar 13 02:07:38 EST 2010
On Saturday, March 13, 2010, Roger André <randre at gmail.com> wrote:
> Hi All,I'm trying to resolve some strange behavior in my OpenLayers map. I am using a BING maps base layer, and a GeoJson feature collection layer. Both layers display in the map, but the GeoJson layer "acts funny". For one thing, it is slightly offset from where it should be located, and for another, it doesn't move with the BING base layer when I pan the map.
> I am trying to follow the instructions at http://docs.openlayers.org/library/spherical_mercator.html#spherical-mercator, which seem to be very well written, but may be slightly out of date? For example, the doc says to instantiate a new VirtualEarth layer by doing this:
>
> var layer = new OpenLayers.Layer.VirtualEarth("Virtual Earth",
> { sphericalMercator: true,
> maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34)
> });
>
>
> But the current examples show using this syntax:
>
> var roads = new OpenLayers.Layer.VirtualEarth("Road Map",
> { type: VEMapStyle.Shaded, numZoomLevels: 21 }
> );
>
>
> In any case, I can't seem to figure out how to apply the projection instructions that are on the doc. Also, I'm not sure if a projection mismatch is causing the problem I'm seeing, but I figure it's a place to start.
>
> Would appreciate some advice regarding how to troubleshoot this.
Hi
<http://trac.openlayers.org/wiki/FrequentlyAskedQuestions#WhydontmyvectorfeaturesworkoverGoogleYahooVirtualEarthetc.>
(this a link to the old FAQ, as the new one is currently out of order.)
You should use the EPSG:900913 projection in your map and set
"sphericalMercator" to true in your VirtualEarch layer. See the
spherical-mercator.html example. Also, the vector data (GeoJSON)
should be in EPSG:900913, unless you reproject it client side. If you
use either the fixed or BBOX strategy set "projection" to the your
data projection (e.g. new OpenLayers.Projection("EPSG:4326")) in the
layer to havr OpenLayers reproject the data to the map projection
before adding it to the layer.
Cheers,
--
Eric Lemoine
Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex
Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com
More information about the Users
mailing list