동적으로 여러 GeoJSON 데이터를 맵에 추가하려고합니다. 아래 그림과 같이. 그러나 데이터가 렌더링되는 것을 보지 못합니다.Angular-leaflet : Ajax 응답에서 여러 geojson을 추가하는 방법
$http.get("/kp-data").success(function(data, status){
angular.forEach(data, function(k,v){
$scope.geojson[k.carId] = {data : k.data,
resetStyleOnMouseout: true,
style: {
fillColor: k.color,
weight: 2,
opacity: 1,
color: 'white',
dashArray: '3',
fillOpacity: 0.7
}
}
});
이 example에서 geojson 데이터 USA와 JPN 하드 코딩된다. 동적 추가 코드를 수정했습니다. 단일 geojson 데이터에 대해 아래와 같이 수정하면 코드가 작동합니다.
$http.get("/kp-data").success(function(data, status){
angular.forEach(data, function(k,v){
if(v==1){
$scope.geojson = {data : k.data,
resetStyleOnMouseout: true,
style: {
fillColor: k.color,
weight: 2,
opacity: 1,
color: 'white',
dashArray: '3',
fillOpacity: 0.7
}
}
}
});
도움을 주신 데 대해 감사드립니다. 감사합니다
예 변수를 선언했습니다. 그렇지 않으면 두 번째 사례가 작동하지 않습니다. –