kdefilip / google-maps-utility-library-v3

Automatically exported from code.google.com/p/google-maps-utility-library-v3
Apache License 2.0
0 stars 0 forks source link

Extra MarkerWithLabel when dragging the object #245

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The following codes is used to add MarkerWithLabel on the map:

     var map;
     function addLatLng(event) {

         var marker = new MarkerWithLabel({
             position: event.latLng,
             draggable: true,
             raiseOnDrag: true,
             map: map,
             labelContent: "$425K",
             labelAnchor: new google.maps.Point(22, 0),
             labelClass: "labels", // the CSS class for the label
             labelStyle: { opacity: 0.75 },
             icon: {}
         });

     }
   function initMap() {
     var latLng = new google.maps.LatLng(49.47805, -123.84716);
     var homeLatLng = new google.maps.LatLng(49.47805, -123.84716);

     map = new google.maps.Map(document.getElementById('map_canvas'), {
       zoom: 12,
       center: latLng,
       mapTypeId: google.maps.MapTypeId.ROADMAP
     });

     google.maps.event.addListener(map, 'click', addLatLng);
   }

After MarkerWithLabel objects are put on the map (via clicking the map), 
dragging these objects will add an extra MarkerWithLabel object on the map.  I 
think the following code of markerwithlabel.js does not work.

google.maps.event.addDomListener(this.eventDiv_, "click", function (e) {
      if (me.marker_.getDraggable() || me.marker_.getClickable()) {
        if (cIgnoreClick) { // Ignore the click reported when a label drag ends
          cIgnoreClick = false;
        } else {
          google.maps.event.trigger(me.marker_, "click", e);
          cAbortEvent(e); // Prevent click from being passed on to map
        }
      }
    }),

Original issue reported on code.google.com by btran1...@gmail.com on 7 Apr 2013 at 2:56

Attachments:

GoogleCodeExporter commented 8 years ago
if I move the following line at the bottom of the if statement
cAbortEvent(e); // Prevent click from being passed on to map

Like this

google.maps.event.addDomListener(this.eventDiv_, "click", function (e) {
      if (me.marker_.getDraggable() || me.marker_.getClickable()) {
        if (cIgnoreClick) { // Ignore the click reported when a label drag ends
            cIgnoreClick = false;
        } else {
          google.maps.event.trigger(me.marker_, "click", e);
        }
        cAbortEvent(e); // Prevent click from being passed on to map
      }
    }),

The problem is fixed.

Original comment by btran1...@gmail.com on 7 Apr 2013 at 3:11

GoogleCodeExporter commented 8 years ago

Original comment by brett.mc...@gmail.com on 15 Jul 2013 at 9:54