Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <head>
- <title>A Leaflet map</title>
- <link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.1/dist/leaflet.css"integrity="sha512Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ=="crossorigin=""/>
- <script type='text/javascript' src='http://code.jquery.com/jquery-1.10.2.min.js?ver=1.10.2'></script>
- <script type='text/javascript' src="https://unpkg.com/leaflet@1.3.1/dist/leaflet.js"integrity="sha512-/Nsx9X4HebavoBvEBuyp3I7od5tA0UzAxs+j83KgC8PU0kgB4XiK4Lfe4y4cgBtaRJQEIFCW+oC506aPT2L1zw=="crossorigin=""></script>
- <div id="map"></div>
- <style>
- #map{ height: 100% }
- </style>
- </head>
- <body>
- <script type="text/javascript">
- var markerArray = [];
- var map = L.map('map').setView([40.730610, -73.935242], 11.5);
- L.tileLayer('https://cartodb-basemaps{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png',
- {
- attribution: '© <a href=" ">OpenStreetMap</a > © <ahref="http://cartodb.com/attributions">CartoDB</a >',
- subdomains: 'abcd',
- maxZoom: 19
- }).addTo(map);
- var url= "http://dev.spatialdatacapture.org:8827/airbnb";
- console.log(url);
- $.getJSON( url, function(data){
- $.each(data, function(k,v){
- var lng = v.longitude;
- var lat = v.latitude;
- var marker = {
- "type":'Feature',
- "properties":
- {
- "id":v.id,
- "host_id":v.host_id,
- "host_listings_count":v.host_listings_count,
- "property_type":v.property_type,
- "room_type":v.room_type,
- "price":v.price,
- "review_scores_rating":v.review_scores_rating,
- "review_scores_accuracy":v.review_scores_accuracy,
- "review_scores_cleaness":v.review_scores_cleaness,
- "review_scores_checkin":v.review_scores_checkin,
- "review_scores_communication":v.review_scores_communication,
- "review_scores_location":v.review_scores_location,
- "review_scores_value":v.review_scores_value,
- "NTACode":v.NTACode,
- "NTAName":v.NTAName,
- },
- "geometry":{
- "type":'Point',
- "coordination" : [lng,lat]
- }
- };
- markerArray.push(marker);
- });
- var geoj = {"type":"FeatureCollection","features": markerArray};
- console.log(geoj);
- L.geoJson(geoj,{
- PointToLayer: function(feature,latLng){
- return
- L.circleMarker(latLng,geojsonMarkerOptions).on('mouseover',function()
- {
- this.bindPopup("NTAName"+feature.properties.NTAName +"</div>
- <div>"+"price"+feature.properties.price+"</div><div>"+"
- </div>").openPopup();
- });
- }
- }).addTo(map);
- });
Add Comment
Please, Sign In to add comment