Ich verwende die OpenLayers Technologie, um Polygon zu zeichnen und die Koordinaten zu speichern. Hier ist mein Code: -Wie konvertiert man OpenLayers-Polygonkoordinaten in Breiten- und Längengrade?
var raster = new ol.layer.Tile({
source: new ol.source.OSM()
});
var source = new ol.source.Vector({wrapX: false});
var vector = new ol.layer.Vector({
source: source
});
var map = new ol.Map({
layers: [raster, vector],
target: 'map',
view: new ol.View({
center: [-11000000, 4600000],
zoom: 4
})
});
var typeSelect = document.getElementById('type');
var draw; // global so we can remove it later
function addInteraction() {
var value = typeSelect.value;
if (value !== 'None') {
draw = new ol.interaction.Draw({
source: source,
type: /** @type {ol.geom.GeometryType} */ (typeSelect.value),
freehand: true
});
draw.on('drawend',function(e){
var polygonString = e.feature.getGeometry().getCoordinates();
//polygonString = polygonString.toString();
//$('#polygonString').val(polygonString);
//$('#myPlot').modal('show');
});
map.addInteraction(draw);
}
}
Die polygonString hat die Koordinaten in Form von
[-12086017.297876,6615491.5618235]
[-12095801.237496,6615491.5618235]
ich diese Werte als Breiten- und Längen speichern möchten. Wie kann ich das machen?