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!!


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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