aytee / 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

cannot change property for MarkerWithLabel #60

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
marker = new MarkerWithLabel({ 
    position: new google.maps.LatLng(locations[i][1], locations[i][2]), 
    title: locations[i][0] + incidents,
    icon: image,
    map: map,
    labelContent: locations[i][0] + incidents,
    labelVisible: false
  }); 

// Add listener to open info window when user clicks on a marker
google.maps.event.addListener(marker, 'click', (function(marker, i) { 
return function() {
    infowindow.setContent(locations[i][4]); 
        infowindow.open(map, marker); 
    google.maps.Marker.set(marker.labelVisible, true);
    } 
})(marker, i)); 
}
*********************************************************
The above code is part of a For statement that places a number of markers on a 
map. I want the label to show only when the user clicks the pin so I initially 
set the labelVisible to false but want to add a property change in the on click 
listener that toggles labelVisible to true.  When I use the 
google.maps.Marker.set(propertyName, propertyValue) to try to accomplish this, 
I get a "object does not this property or method.

I will admit to not being close to an expert, so I'm afraid my trouble may be 
syntax related.  I apologize in advance if this is the case. 

Original issue reported on code.google.com by angiek...@gmail.com on 9 Dec 2010 at 9:32

GoogleCodeExporter commented 9 years ago
I think the problem is in this line:

    google.maps.Marker.set(marker.labelVisible, true);

It should be:

    google.maps.Marker.set("labelVisible", true);

Gary

Original comment by garylitt...@gmail.com on 9 Dec 2010 at 10:15

GoogleCodeExporter commented 9 years ago
On further analysis, the new line should be:

    marker.set("labelVisible", true);

The code you're using to attach the listener looks a bit convoluted so there 
may be other problems as well... or maybe not!

Original comment by garylitt...@gmail.com on 9 Dec 2010 at 10:29

GoogleCodeExporter commented 9 years ago
Thanks Gary! Your second suggestion was right on the nose! 

Original comment by angiek...@gmail.com on 10 Dec 2010 at 1:42

GoogleCodeExporter commented 9 years ago
Closed. This was not a bug in MarkerWithLabel.

Original comment by garylitt...@gmail.com on 11 Dec 2010 at 8:28

GoogleCodeExporter commented 9 years ago
I think this issue came back. I'm not able to set up "lableVisible" 
dynamically. I noticed that the setting of "labelVisible" works until late 2013 
release but doesn't work with 2014 releases. Any input on this would help. 

Original comment by param8...@gmail.com on 13 May 2014 at 6:24

GoogleCodeExporter commented 9 years ago
The property is called "labelVisible" not "lableVisible".

Original comment by g...@garylittle.ca on 13 May 2014 at 6:18

GoogleCodeExporter commented 9 years ago
I'm on:

@name MarkerWithLabel for V3
@version 1.1.10 [April 8, 2014]

and I feel so stupid, because I don't see what I'm doing wrong. This code 
alerts all labels, but does not hide them. Why?

function hideLabels() {

    for (i = 0; i < markers.length; i++) {
        alert(markers[i].labelContent);
        markers[i].set("labelVisible", false)
    }
 }

Original comment by per.g...@gmail.com on 5 Sep 2014 at 3:35