ol-geometry-editor Getting started

Draw a GeoJSON Geometry listening event

Input

Data


Code

html

<!-- map input -->
<input type="text" id="the_geom" class="geometry form-control" name="the_geom" value='{"type":"Point","coordinates":[2.424573,48.845726]}'/>
<!-- data output -->
<div id="result" class="well"></div>

javscript

$('.geometry').geometryEditor();

var geometryEditor = $(".geometry").data('editor');
var map = geometryEditor.getMap();

/* Reading events on geometry changing */
map.on('change:geometry', function (e) {
    var geoJSON = e.geometry;
    var textResult;
    if (!geoJSON) {
        textResult = "No geoJSON geometry found";
    } else {
        textResult = "GeoJSON of geometry drawn : " + geoJSON + ".";
    }
    $("#result").html(textResult);
});