[OpenLayers-Users] Weird issue with restrictedExtent
Tue Topholm
tt at sugee.dk
Wed Nov 2 20:16:00 EDT 2011
Hi All
I have a small issue with restrictedExtent, because makes the extent smaller than the bounds really are.....
around 250 meters to small....
so I can't pan out the bounds....
Here is my code
options = {
controls:[new OpenLayers.Control.TouchNavigation({'dragPanOptions': {enableKinetic: true}})],
units: 'm',
buffer:2
};
var map = new OpenLayers.Map( 'map',options);
layer = new OpenLayers.Layer.OSM( "Simple OSM Map",['http://a.tile.openstreetmap.org/${z}/${x}/${y}.png','http://b.tile.openstreetmap.org/${z}/${x}/${y}.png','http://c.tile.openstreetmap.org/${z}/${x}/${y}.png'],{transitionEffect:'resize'});
map.addLayer(layer);
vlayer = new OpenLayers.Layer.Vector('test');
map.addLayer(vlayer);
var point = new OpenLayers.LonLat(json.longitude, json.latitude).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());
console.log(json);
var accuracy = 800;
if(json.accuracy > accuracy)
accuracy = json.accuracy;
var poly = OpenLayers.Geometry.Polygon.createRegularPolygon(new OpenLayers.Geometry.Point(point.lon,point.lat), accuracy, 20,0);
var poly1 = OpenLayers.Geometry.Polygon.createRegularPolygon(new OpenLayers.Geometry.Point(point.lon,point.lat), accuracy+250, 20,0); //Just for testing....
vlayer.addFeatures([new OpenLayers.Feature.Vector(poly), new OpenLayers.Feature.Vector(poly1)]);
map.setOptions({restrictedExtent:poly1.getBounds()}); //normally poly.getBounds()
map.setCenter(point, 17);
normally I use poly.getBounds(), but there are about 250 meters to small...
the poly1 is the one I used to show the difference....
What I'm doing wrong....
/Tue
More information about the Users
mailing list