-2

이것이 내 첫 번째 맵이며 코딩시 첫 번째 시도입니다. 클러스터 마스크가 choropleth 인 경우 나는 그것을 작동하게 만들 수는 없었습니다. 다음 파일클러스터링 작업을 수행 할 수 없습니다.

<!DOCTYPE html> 
<html> 
<head> 
    <link rel="stylesheet" type="text/css" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" /> 
    <link rel="stylesheet" type="text/css" href="http://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/MarkerCluster.css" /> 
    <link rel="stylesheet" type="text/css" href="http://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/MarkerCluster.Default.css" /> 

    <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js'></script> 
    <script type='text/javascript' src='http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js'></script> 
    <script type='text/javascript' src='http://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/leaflet.markercluster.js'></script> 

의 시작 코드 줄

<script type="text/javascript" src="sectores.js"></script> 
<script type="text/javascript" src="geo.js"></script> 

<body> 
<script> 
$.getJSON("geo.js",function(data){ 
    }); 
    var geo = L.geoJson(data,{ 
     pointToLayer: function(feature,latlng){ 
     var marker = L.marker(latlng,{icon: ratIcon}); 
     marker.bindPopup(feature.properties.geometry.coordinates + '<br/>' + feature.properties.OPEN_DT); 
     return marker; 
     } 
    }); 
    var clusters = L.markerClusterGroup(); 
    clusters.addLayer(geo); 
    map.addLayer(clusters); 
    }); 
</script> 
</body> 

입니다 그리고 이것은 geo.js 마침내 여기

var geo = 
    {"type": "FeatureCollection", 
    "features": [ 
    { 
     "type": "Feature", 
     "properties": { 
     "Fecha": "05/01/2017", 
     "Dia": null, 
     "Hora": null, 
     "Caratula": "Robo", 
     "Pais": "Argentina", 
     "Calle": "CANADA Y ARCACHON", 
     "Localidad": "Pinamar", 
     "Provincia": "Buenos Aires", 
     "Codigo Pos": 7167, 
     "addrtype": "intersection", 
     "addrlocat": "GEOMETRIC_CENTER" 
     }, 
     "geometry": { 
     "type": "Point", 
     "coordinates": [ 
      -56.8951216, 
      -37.1321522 
     ] 
     } 
    }, 

그리고에서 300 점 중 하나입니다 도와주세요; -;

답변

0

나는, 올바른 코드, 그것은 작업이, 그 유일한 라인 I 변경할 필요

var clusterGroup = L.markerClusterGroup(); 
var geojsonLayer = L.geoJson(geo); //where it goes your .js file 
clusterGroup.addLayer(geojsonLayer); 
map.addLayer(clusterGroup); 
} 

그게 전부입니다 수 있도록 그것은 나에게 처음으로 공식 설명에 명확 않네, 내 스스로 그것을 알아 냈 I 이것이 나와 같은 초보자가되기를 바랍니다.

관련 문제