Guest User

Untitled

a guest
May 20th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. <head>
  2. <title>A Leaflet map</title>
  3.  
  4. <link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.1/dist/leaflet.css"integrity="sha512Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ=="crossorigin=""/>
  5.  
  6. <script type='text/javascript' src='http://code.jquery.com/jquery-1.10.2.min.js?ver=1.10.2'></script>
  7.  
  8. <script type='text/javascript' src="https://unpkg.com/leaflet@1.3.1/dist/leaflet.js"integrity="sha512-/Nsx9X4HebavoBvEBuyp3I7od5tA0UzAxs+j83KgC8PU0kgB4XiK4Lfe4y4cgBtaRJQEIFCW+oC506aPT2L1zw=="crossorigin=""></script>
  9.  
  10.  
  11.  
  12. <div id="map"></div>
  13. <style>
  14. #map{ height: 100% }
  15. </style>
  16. </head>
  17.  
  18. <body>
  19. <script type="text/javascript">
  20.  
  21. var markerArray = [];
  22. var map = L.map('map').setView([40.730610, -73.935242], 11.5);
  23. L.tileLayer('https://cartodb-basemaps{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png',
  24. {
  25. attribution: '&copy; <a href=" ">OpenStreetMap</a > &copy; <ahref="http://cartodb.com/attributions">CartoDB</a >',
  26. subdomains: 'abcd',
  27. maxZoom: 19
  28. }).addTo(map);
  29.  
  30. var url= "http://dev.spatialdatacapture.org:8827/airbnb";
  31. console.log(url);
  32.  
  33. $.getJSON( url, function(data){
  34. $.each(data, function(k,v){
  35. var lng = v.longitude;
  36. var lat = v.latitude;
  37.  
  38. var marker = {
  39. "type":'Feature',
  40. "properties":
  41. {
  42. "id":v.id,
  43. "host_id":v.host_id,
  44. "host_listings_count":v.host_listings_count,
  45. "property_type":v.property_type,
  46. "room_type":v.room_type,
  47. "price":v.price,
  48. "review_scores_rating":v.review_scores_rating,
  49. "review_scores_accuracy":v.review_scores_accuracy,
  50. "review_scores_cleaness":v.review_scores_cleaness,
  51. "review_scores_checkin":v.review_scores_checkin,
  52. "review_scores_communication":v.review_scores_communication,
  53. "review_scores_location":v.review_scores_location,
  54. "review_scores_value":v.review_scores_value,
  55. "NTACode":v.NTACode,
  56. "NTAName":v.NTAName,
  57. },
  58. "geometry":{
  59. "type":'Point',
  60. "coordination" : [lng,lat]
  61. }
  62. };
  63.  
  64. markerArray.push(marker);
  65. });
  66. var geoj = {"type":"FeatureCollection","features": markerArray};
  67. console.log(geoj);
  68.  
  69. L.geoJson(geoj,{
  70. PointToLayer: function(feature,latLng){
  71. return
  72. L.circleMarker(latLng,geojsonMarkerOptions).on('mouseover',function()
  73. {
  74. this.bindPopup("NTAName"+feature.properties.NTAName +"</div>
  75. <div>"+"price"+feature.properties.price+"</div><div>"+"
  76. </div>").openPopup();
  77. });
  78. }
  79. }).addTo(map);
  80. });
Add Comment
Please, Sign In to add comment