2011-01-27 5 views
3

나는 바닐라 코드 예제를 사용하는 순간이며 작동하지도 않습니다!Google지도 API v3 맞춤 마커가 표시되지 않음

나는 ... (가) 사용하여 마커를 만들

overlay = new CustomMarker(new google.maps.LatLng(subitem[2], subitem[3]), mapView); 
overlay.setMap(mapView); 

전화 그리고 CustomMarker의 코드는 동일한하는 LatLng를 사용하여 표준 마커를 만들기

function CustomMarker(latlng, map) { 
google.maps.OverlayView.call(this); 

this.latlng_ = latlng; 

// Once the LatLng and text are set, add the overlay to the map. This will 
// trigger a call to panes_changed which should in turn call draw. 
this.set_map(map); 


} 


CustomMarker.prototype = new google.maps.OverlayView(); 

    CustomMarker.prototype.draw = function() { 
var me = this; 

// Check if the div has been created. 
var div = this.div_; 
if (!div) { 
    // Create a overlay text DIV 
    div = this.div_ = document.createElement('DIV'); 
    // Create the DIV representing our CustomMarker 
    div.style.border = "0px solid none"; 
    div.style.position = "absolute"; 
    div.style.paddingLeft = "0px"; 
    div.style.cursor = 'pointer'; 

    var img = document.createElement("img"); 
    img.src = "../../images/tile_images/ship_black_0.png"; 
    div.appendChild(img); 
    google.maps.event.addDomListener(div, "click", function(event) { 
    google.maps.event.trigger(me, "click"); 
    }); 

    // Then add the overlay to the DOM 
    var panes = this.get_panes(); 
    panes.overlayImage.appendChild(div); 
} 

// Position the overlay 
var point = this.get_projection().fromLatLngToDivPixel(this.latlng_); 
if (point) { 
    div.style.left = point.x + 'px'; 
    div.style.top = point.y + 'px'; 
} 


}; 

    CustomMarker.prototype.remove = function() { 
    // Check if the overlay was on the map and needs to be removed. 
    if (this.div_) { 
     this.div_.parentNode.removeChild(this.div_); 
     this.div_ = null; 
    } 
    }; 

    CustomMarker.prototype.get_position = function() { 
    return this.latlng_; 
    }; 

이며지도보기가 잘 작동합니다.

내가 오류

this.set_map(map); 

가되지 않은 것 같습니다

TypeError: Result of expression 'this.set_map' [undefined] is not a function.

답변

3

이며 지금

this.setMap(map); 
입니다
관련 문제