Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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 have a couple questions that are focused around the geometryType property with vector layers. When you create a vector layer you can set the geometryType property to limit the geometry types the layer supports...

{String} geometryType allows you to limit the types of geometries this layer supports. This should be set to something like “OpenLayers.Geometry.Point” to limit types. -- OpenLayers API Docs

but in the Vector.js file the code is looking for an object when checking the geometry

 if (this.geometryType &&
          !(feature.geometry instanceof this.geometryType)) {
            var throwStr = OpenLayers.i18n('componentShouldBe',
            throw throwStr;

Is this a typo in the API Docs or am I doing something wrong here?

On a related note if I set the geometryType of a VectorLayer to be OpenLayers.Geometry.Polygon and then try to edit geometry of features in that layer it doesn't want to work because it tries to insert OpenLayers.Geometry.Point geometries into the layer to represent the draggable vertices.

Is there a something built in to get around this or do I need to write something to handle this?

Thank you for any help.


This seems to work but I'll be running more tests.


    // Override for geometryType.
    var geometryType = options && options.geometryType !== undefined ? options.geometryType : this.geometryType;


// Where "addFeatures" exist I've tacked on the geometryType
this.layer.addFeatures([this.radiusHandle], {silent: true, geometryType: OpenLayers.Geometry.Point});

Thanks for the help!!

share|improve this question
Looks like a bug or document inconsistency to me. I think you should open a ticket at – geographika Dec 8 '11 at 17:08
Looks like a ticket has already been opened (3 years ago :/) – CaptDragon Dec 8 '11 at 18:02
up vote 2 down vote accepted

It's a bug.

You can try modifying vector.js to what this thread suggests might be a solution (at the bottom)

If it does work, post back on that thread letting them know what worked for you.

share|improve this answer

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.