2016-12-09 4 views
0

私は父のウェブサイトの不動産ウェブサイトのHTMLコードを開発しています。 これは私がやりたいことですが、私はマップボックス上に40のマーカーと、エージェンシーのすべての座標を持つ地図を持っています。そして、ポリゴンで研究を実装する必要があります。私のjsonファイルに含まれているすべてのマーカーを表示するために必要な特定の領域です。 私はアヤックスの部分と一緒に行く方法がわからない、助けてください。 すべての作品は、ポリゴンを描くためのマップとインストゥルメントがありますが、ポリゴンを完成させるとマーカーが表示されませんが、正しい変数には接続されていないため、 jsonファイルの(latlong)。

これは私が今まで何をやったかである: -

{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"id":"marker-iwb5nwz22","title":"Cinisello Balsamo","description":"","marker-size":"medium","marker-color":"#26852A","marker-symbol":""},"geometry":{"coordinates":[9.2218,45.5571],"type":"Point"},"id":"0087f60eb6b6cdae6cb1ccc458964942"},{"type":"Feature","properties":{"id":"marker-iwb5qyt0d","title":"Giussano","description":"","marker-size":"medium","marker-color":"#26852A","marker-symbol":""},"geometry":{"coordinates":[9.2112,45.6941],"type":"Point"},"id":"1c5fd76f572645fff7da2b705382c4c9"},{"type":"Feature","properties":{"id":"marker-iwb5oaqe3","title":"Monza","description":"","marker-size":"medium","marker-color":"#26852A","marker-symbol":""},"geometry":{"coordinates":[9.2749,45.5864],"type":"Point"},"id":"1c7efc5ae8a12f635f44e4fea3095d01"},{"type":"Feature","properties":{"id":"marker-iwb5ojra4","title":"Paderno Dugnano","description":"","marker-size":"medium","marker-color":"#26852A","marker-symbol":""},"geometry":{"coordinates":[9.1634,45.5731],"type":"Point"},"id":"24c45843c9ee95b94681568b3fe41bd0"},{"type":"Feature","properties":{"id":"marker-iwb5h0fl0","title":"Bresso","description":"","marker-size":"medium","marker-color":"#26852A","marker-symbol":""},"geometry":{"coordinates":[9.1975,45.5379],"type":"Point"},"id":"34548447bec6dfd7471d5ec354288f3e"},{"type":"Feature","properties":{"id":"marker-iwb5qegjb","title":"Seregno","description":"","marker-size":"medium","marker-color":"#26852A","marker-symbol":""},"geometry":{"coordinates":[9.2052,45.6501],"type":"Point"},"id":"37722a0c0498c5db0866c4743ecd6e0e"},{"type":"Feature","properties":{"id":"marker-iwb5q8sda","title":"Sesto San Giovanni","description":"","marker-size":"medium","marker-color":"#26852A","marker-symbol":""},"geometry":{"coordinates":[9.2417,45.5394],"type":"Point"},"id":"37a88632dc9725a38c5ff5820c11c409"},{"type":"Feature","properties":{"id":"marker-iwb5qjnlc","title":"Limbiate","description":"","marker-size":"medium","marker-color":"#26852A","marker-symbol":""},"geometry":{"coordinates":[9.129,45.5968],"type":"Point"},"id":"58d9c9d9a0270c6d19a4552c8e2be29e"},{"type":"Feature","properties":{"id":"marker-iwb5nls81","title":"Cusano Milanino","description":"","marker-size":"medium","marker-color":"#26852A","marker-symbol":""},"geometry":{"coordinates":[9.1834,45.5531],"type":"Point"},"id":"66e41c85168a84369bc0e5fdf0b6ce88"},{"type":"Feature","properties":{"id":"marker-iwb5q3vb9","title":"Milano","description":"","marker-size":"medium","marker-color":"#26852A","marker-symbol":""},"geometry":{"coordinates":[9.1895,45.4643],"type":"Point"},"id":"71cbc062b709f50a5b4a3161277e6ccf"},{"type":"Feature","properties":{"id":"marker-iwb5oy4d6","title":"Muggiò","description":"","marker-size":"medium","marker-color":"#26852A","marker-symbol":""},"geometry":{"coordinates":[9.2262,45.5884],"type":"Point"},"id":"8d8f997e744adb924b70487893a2e3cf"},{"type":"Feature","properties":{"id":"marker-iwb5pc0n8","title":"Baranzate","description":"","marker-size":"medium","marker-color":"#26852A","marker-symbol":""},"geometry":{"coordinates":[9.1172,45.5272],"type":"Point"},"id":"c167525db8d8c9dbbaa35c57623a6bdc"},{"type":"Feature","properties":{"id":"marker-iwb5p4sj7","title":"Rho","description":"","marker-size":"medium","marker-color":"#26852A","marker-symbol":""},"geometry":{"coordinates":[9.0401,45.5309],"type":"Point"},"id":"d4393729360e4b928f24b9f09c8865eb"},{"type":"Feature","properties":{"id":"marker-iwb5oq065","title":"Cormano","description":"","marker-size":"medium","marker-color":"#26852A","marker-symbol":""},"geometry":{"coordinates":[9.1709,45.5396],"type":"Point"},"id":"e756bae22ebcd7819cc28386f4438091"},{"type":"Feature","properties":{"id":"marker-iwb5r4yle","title":"Lissone","description":"","marker-size":"medium","marker-color":"#26852A","marker-symbol":""},"geometry":{"coordinates":[9.2465,45.6156],"type":"Point"},"id":"fa49afd510ac340c2d6ed5787aafaaf0"}],"id":"fabiobarosi.29l7anjh"} 

<html> 
 
<head> 
 
<title>Map Search</title> 
 

 
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" /> 
 
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/0.2.3/leaflet.draw.css" /> 
 
<!--[if lte IE 8]><link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.ie.css" /><![endif]--> 
 

 
<script src="https://code.jquery.com/jquery-1.10.2.js"></script> 
 
<script src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script> 
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/0.2.3/leaflet.draw.js"></script> 
 

 
<script language="javascript"> 
 
$(document).ready(function() { 
 

 
    var map = new L.Map('map'); 
 

 
    var MapBox = L.tileLayer('http://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoiZmFiaW9iYXJvc2kiLCJhIjoiY2l3YjNqZ2ViMDAydTJ5cDRqMXl2NHZ2ciJ9.bv8ndwbT2ItNCoz2gH13XA', { 
 
\t attribution: 'Imagery from <a href="http://mapbox.com/about/maps/">MapBox</a> &mdash; Map data &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>', 
 
\t subdomains: 'abcd', 
 
\t id: 'fabiobarosi.29l7anjh', 
 
accessToken:'pk.eyJ1IjoiZmFiaW9iYXJvc2kiLCJhIjoiY2l3YjNqZ2ViMDAydTJ5cDRqMXl2NHZ2ciJ9.bv8ndwbT2ItNCoz2gH13XA' 
 
}).addTo(map); 
 

 
    var bresso = new L.LatLng(45.53792, 9.18921); 
 
    map.setView(bresso,10); 
 

 
    var drawnItems = new L.FeatureGroup(); 
 
    map.addLayer(drawnItems); 
 

 
    var drawControl = new L.Control.Draw({ 
 
     edit: { 
 
      featureGroup: drawnItems 
 
     } 
 
    }); 
 

 
    map.addControl(drawControl); 
 
    map.on('draw:created', function (e) { 
 
     var latLngs = $.map(e.layer.getLatLngs(), function(o) { 
 
      return { name: "points", value: o.lat + "," + o.lng }; 
 
     }); 
 

 
     $.ajax({ 
 
     
 
      type: 'GET', 
 
      dataType: 'json', 
 
      url: 'https://www.dropbox.com/s/3m57o54cluj4enq/features-2.json?dl=0', 
 
      success: function(data) { 
 
       $.each (data, function (idx) { 
 
        var markerLocation = new L.LatLng(data[idx].geo.lat, data[idx].geo.lng); 
 
        var marker = new L.Marker(markerLocation); 
 
        map.addLayer(marker); 
 
       }); 
 
      } 
 
     }); 
 

 
     map.addLayer(e.layer); 
 
    }); 
 
}); 
 
</script> 
 

 
</head> 
 
<body> 
 
    <div id="map" style="height: 100%"></div> 
 
</body> 
 
</html>

+0

詳細情報を追加してください。これには、あなたがすでに試したこと、働いている/していないこと、誰かがあなたの質問に答えるのを助けるかもしれない他の情報が含まれます。 –

+0

この情報を編集して質問に追加してください! –

答えて

0

あり、この例で複数の問題がありますが、最初のものは、このAJAXリクエストが勝ったということでしょうDropboxはhave CORS enabledではないので、WebページからDropboxから何かを要求することはできません。 cross-origin resource sharingを実行するには、(同じサーバー上の)スクリプトのローカルリソースを持つか、リソースを保持するサーバー上でCORSを有効にする必要があります。

関連する問題