Openlayers and Bing Maps (POLYGONS)
- by Jordan
When trying to draw polygons onto a bing map, the initial marker is set differently on the map. How can I fix this?
OpenLayers Bing Example
<script src="OpenLayers.js"></script>
<script>
var map;
function init(){
map = new OpenLayers.Map("map");
map.addControl(new OpenLayers.Control.LayerSwitcher());
var shaded = new OpenLayers.Layer.VirtualEarth("Shaded", {
type: VEMapStyle.Shaded
});
var hybrid = new OpenLayers.Layer.VirtualEarth("Hybrid", {
type: VEMapStyle.Hybrid
});
var aerial = new OpenLayers.Layer.VirtualEarth("Aerial", {
type: VEMapStyle.Aerial
});
var POLY_LAYER = new OpenLayers.Layer.Vector();
map.addLayers([shaded, hybrid, aerial, POLY_LAYER]);
map.setCenter(new OpenLayers.LonLat(-110, 45), 3);
var polygon = new OpenLayers.Control.DrawFeature(POLY_LAYER, OpenLayers.Handler.Polygon);
map.addControl(polygon);
polygon.activate();
}
</script>
Bing Example
<div id="tags">
Bing, Microsoft, Virtual Earth
</div>
<p id="shortdesc">
Demonstrates the use of Bing layers.
</p>
<div id="map" class="smallmap"></div>
<div id="docs">This example demonstrates the ability to create layers using tiles from Bing maps.</div>
Of course the above is being initialized and page works. You can draw the polygon shapes. Notice if you zoom in or out one time, the markers are set at the correct coordinates.
My app I was testing this on is really using the bing maps API keys and not VirtualEarth. But it's doing a similar thing.
Is this an Openlayers bug?
The below source came directly from the open layers example site, I just added and activated polygons to the map.
Please let me know how I can fix this for using the Bing Map API.. I've been stuck on this for HOURS!
:(