3

어떻게 이것을 v3으로 포팅 할 수 있습니까? removeOverlay는 v3에 포함되어 있지 않습니다.Google지도 API v3의 removeOverlay

if(mapElements[lMapElementIndex]['marker'] != 0){ 
    //map.removeOverlay(mapElements[lMapElementIndex]['marker']); V2 
} 

V3?

if(mapElements[lMapElementIndex]['marker'] != 0){ 
    //map.removeOverlay(mapElements[lMapElementIndex]['marker']); 
    mapElements(mapElements[lMapElementIndex]['marker']).setMap(null); 
} //but throws an error mapElements is not a function 

답변

4

오버레이의 방법은 setMap이어야합니다. From the docs :

는,지도에서 오버레이를 제거 오버레이의 setMap() 메소드를 호출하려면, 는 null를 전달합니다. mapElements 가정

은 객체의 배열, 그리고 marker 속성이 오버레이 인스턴스를 참조하는 것이, 당신이 할 필요는 다음과 같습니다

mapElements[lMapElementIndex]['marker'].setMap(null); 

귀하의 시도는 당신이하려고하기 때문에 오류가 발생합니다 mapElements을 함수로 호출하십시오 (배열 인 것으로 보이는 경우). 그럴 필요가 없습니다. 그냥 함수 호출을 제거하고 잘 작동합니다.

+0

감사합니다 setMap (null) ... 알고 있지만 rlly 확실히이 removeFromMap (lMapElementIndex) 함수를 변경하려면 어떻게합니까 (http://pastebin.com/EFwnngnR 참조) 줄 : 573 – Jim

+0

At 언뜻 보면 591 행을 내 대답의 코드 행으로 변경해야하는 것처럼 보입니다. 현재 당신은'setMap'을 단지 숫자 일 것이라고 생각하고 있습니다. –

+0

오류 제가 \t로 변경 사라진 경우 '(mapElements [lMapElementIndex] ['마커 ']! = 0) { \t \t //map.removeOverlay(mapElements[lMapElementIndex]['marker']); v2 \t \t mapElements [lMapElementIndex] [ 'marker']. setMap (null); \t \t console.log ("[lMapElementIndex] [ 'marker'] Löschen"); \t} ' – Jim

관련 문제