Restrict google maps API marker to only one click per marker

cubanGuy

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?

Carlos2W

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] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Making Google maps marker array global breaks marker click event

분류에서Dev

Persistent title with marker in Google Maps Api v2

분류에서Dev

Using SharedPreferences only saves one marker and not the image that goes with that marker

분류에서Dev

Adding marker on Google Maps using a button

분류에서Dev

Google Maps Android Undo Marker Drag

분류에서Dev

Parse JSON response for Google Maps Marker in Android

분류에서Dev

Google Maps API v2 for Android: Marker and Polyline position mismatch

분류에서Dev

Google Maps API v3- Create a marker property that contains content from other properties?

분류에서Dev

How to create a direct link to access a specific Google Maps API V3 marker?

분류에서Dev

@ react-google-maps Marker LatLng throwing 오류

분류에서Dev

Need Google Maps to open Multiple Marker Popups with Fancybox

분류에서Dev

Why are my google maps marker positions all offset by about an inch?

분류에서Dev

How to set the marker color to black in google maps android

분류에서Dev

How to add a marker in `Google Maps` view in Objective-C(iOS)

분류에서Dev

google.maps.event.trigger (geoXml.docs [0] .placemarks [0] .marker, 'click')이 작동하지 않습니다.

분류에서Dev

React Native Maps Custom Marker 차단 Marker onPress

분류에서Dev

Google Maps Javascript API, Marker 및 Polylines 관련 문제가 React.js 앱에 함께 표시되지 않음

분류에서Dev

Android Google Map Marker With Label?

분류에서Dev

Google Maps Marker Shadow가 표시되지 않음

분류에서Dev

Google Maps jQuery Marker가 표시되지 않음

분류에서Dev

how to get the coordinates of google maps marker and store it in textbox or label using asp.net c#

분류에서Dev

Google Maps Marker Clusterer : 중첩 된 클릭 처리

분류에서Dev

함수 호출시 Google Maps Circle 및 Marker 다시 그리기

분류에서Dev

태그를 기반으로 Android Google Maps Marker를 제거 할 수 있습니까?

분류에서Dev

Google Maps Marker Clusterer Plus로 혼합 콘텐츠 경고를 방지하는 방법

분류에서Dev

Google Maps Marker Clusterer-위치 색인과 함께 infoWindow를 사용하는 방법

분류에서Dev

Google Maps Simple Multiple Marker 예제 6 개의 마커가 작동하지 않음

분류에서Dev

Google map marker not displaying dynamically via ajax

분류에서Dev

Change Google Map marker color with external jQuery

Related 관련 기사

  1. 1

    Making Google maps marker array global breaks marker click event

  2. 2

    Persistent title with marker in Google Maps Api v2

  3. 3

    Using SharedPreferences only saves one marker and not the image that goes with that marker

  4. 4

    Adding marker on Google Maps using a button

  5. 5

    Google Maps Android Undo Marker Drag

  6. 6

    Parse JSON response for Google Maps Marker in Android

  7. 7

    Google Maps API v2 for Android: Marker and Polyline position mismatch

  8. 8

    Google Maps API v3- Create a marker property that contains content from other properties?

  9. 9

    How to create a direct link to access a specific Google Maps API V3 marker?

  10. 10

    @ react-google-maps Marker LatLng throwing 오류

  11. 11

    Need Google Maps to open Multiple Marker Popups with Fancybox

  12. 12

    Why are my google maps marker positions all offset by about an inch?

  13. 13

    How to set the marker color to black in google maps android

  14. 14

    How to add a marker in `Google Maps` view in Objective-C(iOS)

  15. 15

    google.maps.event.trigger (geoXml.docs [0] .placemarks [0] .marker, 'click')이 작동하지 않습니다.

  16. 16

    React Native Maps Custom Marker 차단 Marker onPress

  17. 17

    Google Maps Javascript API, Marker 및 Polylines 관련 문제가 React.js 앱에 함께 표시되지 않음

  18. 18

    Android Google Map Marker With Label?

  19. 19

    Google Maps Marker Shadow가 표시되지 않음

  20. 20

    Google Maps jQuery Marker가 표시되지 않음

  21. 21

    how to get the coordinates of google maps marker and store it in textbox or label using asp.net c#

  22. 22

    Google Maps Marker Clusterer : 중첩 된 클릭 처리

  23. 23

    함수 호출시 Google Maps Circle 및 Marker 다시 그리기

  24. 24

    태그를 기반으로 Android Google Maps Marker를 제거 할 수 있습니까?

  25. 25

    Google Maps Marker Clusterer Plus로 혼합 콘텐츠 경고를 방지하는 방법

  26. 26

    Google Maps Marker Clusterer-위치 색인과 함께 infoWindow를 사용하는 방법

  27. 27

    Google Maps Simple Multiple Marker 예제 6 개의 마커가 작동하지 않음

  28. 28

    Google map marker not displaying dynamically via ajax

  29. 29

    Change Google Map marker color with external jQuery

뜨겁다태그

보관