sending post data(geojson) jquery in asp.net core
using openlayers to get location from map.
get coordinates like this
[32.80144214630127, 39.96892690658569]
need to seperate them into latitude and longitude to post
function savetodb() {
// get array of all features
var featureArray = drawSource.getFeatures()
// Define geojson format
var geogJONSformat = new ol.format.GeoJSON()
// Use method to convert feature to geojson
var featuresGeojson = geogJONSformat.writeFeaturesObject(featureArray)
// Array of all geojson
var geojsonFeatureArray = featuresGeojson.features
for (i = 0; i < geojsonFeatureArray.length; i++) {
console.log(geojsonFeatureArray[i].geometry.coordinates)
}
posting line
$.post({
url: "https://localhost:44330/Products",
data: {
"name": "string",
"latitude": 0,
"longitude":0
}
})
couldnt figure it out how to put these coordinates into latitude and longitude lines
Read more here: Source link