Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "type":"FeatureCollection",
- "features":[
- {
- "id":1,
- "type":"Feature",
- "properties":{},
- "geometry":{
- "type":"Polygon",
- "coordinates":[
- [
- [6.146185398101807,46.447689601949826],
- [6.146475076675416,46.44726084421887],
- [6.1472368240356445,46.44776352535544],
- [6.1466360092163095,46.447833752497885],
- [6.146185398101807,46.447689601949826]
- ]
- ]
- }
- },
- {
- "id":"id",
- "type":"Feature",
- "properties":{},
- "geometry":{
- "type":"Polygon",
- "coordinates":[
- [
- [6.146185398101807,46.447689601949826],
- [6.146475076675416,46.44726084421887],
- [6.1472368240356445,46.44776352535544],
- [6.1466360092163095,46.447833752497885],
- [6.146185398101807,46.447689601949826]
- ]
- ]
- }
- }
- ]
- }
- map.on(L.Draw.Event.CREATED, function (e) {
- var type = e.layerType,
- layer = e.layer;
- FGgpx.addLayer(layer);
- var shape = layer.toGeoJSON()
- var shape_for_db = JSON.stringify(shape);
- console.log("Create");
- console.log(shape_for_db);
- // Save to db
- saveGeofences(1,shape_for_db);
- });
- function getGeofences(devise_id){
- $.ajax({
- type: "POST",
- url: "maps/sql/getGeofences.php",
- //data: {data:data},
- data: {devise_id:devise_id},
- success: result,
- error: error,
- dataType: "json"
- });
- function error(data)
- {
- console.log("Error getGeofences");
- console.log(data);
- }
- function result(data){
- console.log("Geofences from DB");
- console.log(data);
- // How can I add a layer with the polygons to my map
- //FGgpx.addLayer(data); // This does not works
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement