Friday, 15 April 2016

Openlayers - Vector layer polygon doesn't move in-synch with Google V3 baselayers


When a polygon is drawn on the map and the map is dragged, the position of the polygon relative to the GM V3 base changes.


function init() {
var map = new OpenLayers.Map('map');
var gsat = new OpenLayers.Layer.Google(
"Google Satellite",
{type: google.maps.MapTypeId.SATELLITE, numZoomLevels: 22}
);

drawVctr = new OpenLayers.Layer.Vector("Editable Vector");
map.addLayers([gsat, drawVctr]);

// Google.v3 uses EPSG:900913 as projection, so we have to
// transform our coordinates
var lng = "-71.118004";
var lat = "42.389118";
map.setCenter(new OpenLayers.LonLat(lng, lat).transform(
new OpenLayers.Projection("EPSG:4326"),
map.getProjectionObject()

), 19);
drawPlygn = new OpenLayers.Control.DrawFeature(
drawVctr,
OpenLayers.Handler.Polygon
);
map.addControl(drawPlygn);
}


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...