[OpenLayers-Users] Feature does not appear in every zoom level

Christoph Lingg christoph at lingg.eu
Tue Aug 3 10:28:55 EDT 2010


Hi list,

I encountered a strange behavior I don't understand: Sometimes I want to cover my whole world map with a dark layer except a distinct region. This is meant to  emphasize a certain region of the world. My approach is creating a polygon with the size of the earth and a hole with the region of interest. Looks like this:
> 			var world = new OpenLayers.Geometry.LinearRing([new OpenLayers.Geometry.Point(-20037508.34, -20037508.34), new OpenLayers.Geometry.Point(-20037508.34, 20037508.34), new OpenLayers.Geometry.Point(20037508.34, 20037508.34), new OpenLayers.Geometry.Point(20037508.34, -20037508.34)]);
> 			var hole = new OpenLayers.Geometry.LinearRing([new OpenLayers.Geometry.Point(r.x1, r.y1), new OpenLayers.Geometry.Point(r.x1, r.y2), new OpenLayers.Geometry.Point(r.x2, r.y2), new OpenLayers.Geometry.Point(r.x2, r.y1)]);
> 			var geo = new OpenLayers.Geometry.Polygon([world, hole]);
> 
> 			this.ftr = new OpenLayers.Feature.Vector(geo, null, {fill: '#000000'});
> 			layer.addFeatures([this.ftr]);
Everything is black except the region, perfect! But after zooming in, the feature always disappears after a certain zoom level. Maybe the feature is too big?

Do you have an explanation, a solution or a better approach for this requirement?

Cheers,
Christoph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100803/1dfd8365/attachment.html


More information about the Users mailing list