Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. {
  2. "type":"FeatureCollection",
  3. "features":[
  4. {
  5. "id":1,
  6. "type":"Feature",
  7. "properties":{},
  8. "geometry":{
  9. "type":"Polygon",
  10. "coordinates":[
  11. [
  12. [6.146185398101807,46.447689601949826],
  13. [6.146475076675416,46.44726084421887],
  14. [6.1472368240356445,46.44776352535544],
  15. [6.1466360092163095,46.447833752497885],
  16. [6.146185398101807,46.447689601949826]
  17. ]
  18. ]
  19. }
  20. },
  21. {
  22. "id":"id",
  23. "type":"Feature",
  24. "properties":{},
  25. "geometry":{
  26. "type":"Polygon",
  27. "coordinates":[
  28. [
  29. [6.146185398101807,46.447689601949826],
  30. [6.146475076675416,46.44726084421887],
  31. [6.1472368240356445,46.44776352535544],
  32. [6.1466360092163095,46.447833752497885],
  33. [6.146185398101807,46.447689601949826]
  34. ]
  35. ]
  36. }
  37. }
  38. ]
  39. }
  40.  
  41. map.on(L.Draw.Event.CREATED, function (e) {
  42. var type = e.layerType,
  43. layer = e.layer;
  44.  
  45.  
  46. FGgpx.addLayer(layer);
  47.  
  48. var shape = layer.toGeoJSON()
  49. var shape_for_db = JSON.stringify(shape);
  50.  
  51. console.log("Create");
  52. console.log(shape_for_db);
  53. // Save to db
  54.  
  55. saveGeofences(1,shape_for_db);
  56. });
  57.  
  58. function getGeofences(devise_id){
  59. $.ajax({
  60. type: "POST",
  61. url: "maps/sql/getGeofences.php",
  62. //data: {data:data},
  63. data: {devise_id:devise_id},
  64. success: result,
  65. error: error,
  66. dataType: "json"
  67. });
  68.  
  69. function error(data)
  70. {
  71. console.log("Error getGeofences");
  72. console.log(data);
  73. }
  74.  
  75. function result(data){
  76. console.log("Geofences from DB");
  77. console.log(data);
  78.  
  79. // How can I add a layer with the polygons to my map
  80. //FGgpx.addLayer(data); // This does not works
  81.  
  82. }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement