2014-10-29 3 views
1

지도에있는 폴리선을 제거하는 방법을 알고있는 사람이 있습니까? 나는 taht가 그려진 선을 제거하기 위하여 많은 것을 시도했다. 그러나 그것은 사라지지 않을 것입니다. 이 선을 그릴 때 사용한 코드는 다음과 같습니다.지도에서지도의 폴리 라인 제거

var geojson = [ 
    { 
    "type": "Feature", 
    "geometry": { 
     "type": "LineString", 
     "coordinates": [ 
     [10.39799, 63.43074], 
     [10.3987, 63.431] 
     ] 
    }, 
    "properties": { 
     "stroke": "#fc4353", 
     "stroke-width": 5 
    } 
    },{ 
    "type": "Feature", 
    "geometry": { 
     "type": "LineString", 
     "coordinates": [ 
     [10.397958755, 63.431], 
     [10.39868, 63.43073] 
     ] 
    }, 
    "properties": { 
     "stroke": "#fc4353", 
     "stroke-width": 5 
    } 
    } 
]; 

L.geoJson(geojson, { style: L.mapbox.simplestyle.style }).addTo(map); 

답변

3

변수에 추가 된 내용을 저장합니다. 그런 다음 map.removeLayer을 사용하십시오. 당신

var layer = L.geoJson(geojson, { style: L.mapbox.simplestyle.style }).addTo(map); 
map.removeLayer(layer); 

https://www.mapbox.com/mapbox.js/api/v2.1.4/l-map-class/#map-stuff-methods

+0

감사합니다. 도움이되었습니다. – Runee

+0

답변을 수락하는 것을 잊지 마십시오. – Heikki

+0

@Heikki 안드로이드/자바에서 이것을 어떻게 얻는가? – Erum