Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I draw flag feature on my map as follows:

myVectorLayer = new OpenLayers.Layer.Vector("Flag Geometry", {
renderers: renderer,
isBaseLayer: true,
projection: new OpenLayers.Projection("EPSG:900913"),
styleMap: new OpenLayers.StyleMap({
    "default": new OpenLayers.Style(OpenLayers.Util.applyDefaults({
        fillColor: "red",
        strokeColor: "gray",
        label: "${label}",
        fontColor: "${favColor}",
        fontSize: "12px",
        fontFamily: "Courier New, monospace",
        fontWeight: "bold",
        labelYOffset: 2 //for flag
        "select": new OpenLayers.Style(OpenLayers.Util.applyDefaults({

var pointList = [];
var xs = [0, 0, 240, 240, 8, 8, 0];
var ys = [0, 280, 280, 120, 120, 0, 0];

for(var p=0; p<6; ++p) {
    var newPoint = new OpenLayers.Geometry.Point(camera.get('latitude') + xs[p],
        camera.get('longitude') + ys[p]);

var linearRing = new OpenLayers.Geometry.LinearRing(pointList);
var flagVector = new OpenLayers.Feature.Vector(
        new OpenLayers.Geometry.Polygon([linearRing]));

flagVector.attributes= {
    label: 'label',
    favColor: 'blue', //favorite color
    align: "cm"

This zooms by default when zooming the map but when zooming out the feature becomes so small that it disappears. Is there a way to limit this zooming effect for the feature so that it stops zooming out the feature after a certain level?

share|improve this question

You can control this with for example

minScale: 54168.1

On the layer, or use style rule and use :

    maxScaleDenominator: 60000000,
    minScaleDenominator: 433344,

The values are of course not hardcoded. That will let you control the layout depending on any zoomlevel.

I've written a more detailed code sample here , hope this helps.

edit: Can't seem to get this to get drawn in jsfiddle, feel free to fork/edit and let me know:

share|improve this answer
Unfortunately none of these ways affect the geometry drawn in this above mentioned way. – Marwa Hack Oct 17 '12 at 13:11
What way are you expecting it to behave ? Not so sure If I truly get the issue now. – Glenn Plas Oct 17 '12 at 14:02
Using Renederer.Symbol as mentioned here… minScale works perfectly, but then I face this geometry center problem. – Marwa Hack Oct 17 '12 at 14:25
Trying your code, I get this: ReferenceError: camera is not defined so I suspect it's defined before the copy/paste. Any chance to fill out the blanks, I got a jsfiddle -almost- working – Glenn Plas Oct 17 '12 at 14:48
camera.get('latitude') & camera.get('longitude') can be replaced by any valid latitude/longitude values e.g. 3658281.05255/4855543.17503 – Marwa Hack Oct 17 '12 at 14:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.