wkt format added

parent 90d4d639
...@@ -99,7 +99,7 @@ OpenStreetMapsClass.prototype.addPolygon = function(coords) ...@@ -99,7 +99,7 @@ OpenStreetMapsClass.prototype.addPolygon = function(coords)
this.vectorLayer.getSource().addFeature(feature); this.vectorLayer.getSource().addFeature(feature);
// show coords // show coords
document.getElementById("id_polygon").value = feature.getGeometry().clone().transform( 'EPSG:3857', 'EPSG:4326').getCoordinates(); this.showCoords(feature.getGeometry());
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/** /**
...@@ -153,14 +153,15 @@ OpenStreetMapsClass.prototype.formatCoords = function(coords) ...@@ -153,14 +153,15 @@ OpenStreetMapsClass.prototype.formatCoords = function(coords)
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/** /**
* set value in input with wkt format * show values of a polygon with wkt format
* POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10)) * POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))
* MULTIPOLYGON (((40 40, 20 45, 45 30, 40 40)),((20 35, 10 30, 10 10, 30 5, 45 20, 20 35),(30 20, 20 15, 20 25, 30 20))) * MULTIPOLYGON (((40 40, 20 45, 45 30, 40 40)),((20 35, 10 30, 10 10, 30 5, 45 20, 20 35),(30 20, 20 15, 20 25, 30 20)))
* @param coords to draw * @param geometry the geometry to show e.g. a polygon
*/ */
OpenStreetMapsClass.prototype.setPolygonInputValue = function(coords) OpenStreetMapsClass.prototype.showCoords = function(geometry)
{ {
// todo var wkt = new ol.format.WKT();
document.getElementById("id_polygon").value = wkt.writeGeometry(geometry.clone().transform( 'EPSG:3857', 'EPSG:4326'));
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/** /**
......
...@@ -118,11 +118,11 @@ sidtMap.prototype.addInteraction = function() ...@@ -118,11 +118,11 @@ sidtMap.prototype.addInteraction = function()
}); });
this.interaction.on("drawend",function(e){ this.interaction.on("drawend",function(e){
document.getElementById("id_polygon").value =e.feature.getGeometry().clone().transform( 'EPSG:3857', 'EPSG:4326').getCoordinates(); self.showCoords(e.feature.getGeometry());
}); });
this.interaction.on("drawstart",function(e){ this.interaction.on("drawstart",function(e){
self.vectorLayer.getSource().clear(); self.removePolygon();
}); });
this.map.addInteraction(this.interaction); this.map.addInteraction(this.interaction);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment