I'm creating a simple map Phonegap app where you click the map, and a marker is added, and a popup form shows. This is working just fine, but I need to make sure each marker is clickable only once.
This is what I've tried so far:
google.maps.event.addListener(clickMarker, 'click',
function (e) {
addLocations(this.getPosition()); // calls popup form
/* clickMarker.setOptions({
clickable: false
});*/
clickMarker.setClickable(false);
});
Is what I'm asking possible? If it is possible, what am I doing wrong?
no, instead of set the clickable to false, try removing the event listener
clickMarker.addListener('click', //add the listener to your marker object directly
function (e) {
addLocations(this.getPosition()); // calls popup form
// Do ever things you want to do before calling this
// Removing the event, so we can just call once
google.maps.event.clearListeners(clickMarker, "click"); // don't forget the 's'
});
Since you're working with phonegap, I strongly suggest you to use this plugin for google maps, it'll be easier :
https://github.com/wf9a5m75/phonegap-googlemaps-plugin
-- Carlos :-)
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다