Thursday 27 August 2015

javascript - OpenLayers 3 doesn't want to draw programmatically a polygon


I am using OpenLayers 3 and I am trying to draw a polygon using given coordinates, but it doesn't want to draw it.



var source = new ol.source.Vector();

var ring = [
[3139880.24789847, 5961935.332187176], [3179627.5026067616, 5972025.01992082],
[3146606.706387566, 5927997.291628557], [3186353.9610958574, 5939615.719927904]];

draw = new ol.interaction.Draw({
source: source,
type: 'Polygon',
geometryFunction: ring,

});

draw.on('drawend', function (e) {
var id = guid();
e.feature.featureID = id;
e.feature.setProperties({
'id': id,
'name': 'Polygon',
'description': 'Some values'
})

map.removeInteraction(draw);
});
map.addInteraction(draw);


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...