Generate geojson in javascript

This commit is contained in:
Jonny Barnes 2017-06-17 11:49:47 +01:00
parent 0a621cd021
commit c17ef7d927
3 changed files with 42 additions and 30 deletions

View file

@ -55,10 +55,15 @@ const makeMapMenu = (map) => {
//the main function
export default function addMap(div, position = null, places = null) {
let data;
let dataLatitude = div.dataset.latitude;
let dataLongitude = div.dataset.longitude;
let data = window['geojson'+div.dataset.id];
if (data == null) {
let dataName = div.dataset.name;
let dataMarker = div.dataset.marker;
if (dataMarker == '') {
dataMarker = 'circle';
}
if (dataName == null) {
data = {
'type': 'FeatureCollection',
'features': [{
@ -74,6 +79,21 @@ export default function addMap(div, position = null, places = null) {
}
}]
};
} else {
data = {
'type': 'FeatureCollection',
'features': [{
'type': 'Feature',
'geometry': {
'type': 'Point',
'coordinates': [dataLongitude, dataLatitude]
},
'properties': {
'title': dataName,
'icon': dataMarker,
}
}]
};
}
if (places != null) {
for (let place of places) {