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

Change of color for marker label ('labelClass') does not work when switching map type #115

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Demo link or sample code:
http://eqinfo.ucsd.edu/~rnewman/howtos/maps/maps_utility/

What steps will reproduce the problem?
1.Load the page above
2.Change the map type to 'hybrid' or 'satellite'

Expected result:
The label on the marker should change it's class from 'gmapLabelsBlk' to 
'gmapsLabelsWhite', which should change the color of the text of the label from 
black to white (based on the CSS defined in the page). Changing the map type 
again should change the color either back to black or it should remain white.

Actual result:
The label color never changes. Outputting the labelClass value to the 
console.log() shows that the MarkerWithLabel object has updated correctly, but 
the value never propagates to the map display.

Version: 1.1.5

Browser / Operating System:
FF6 / MacOSX 10.6.8

Additional comments:

Original issue reported on code.google.com by robertln...@gmail.com on 22 Aug 2011 at 7:02

GoogleCodeExporter commented 9 years ago
You are not using the correct technique for changing the value of labelClass. 
In your maptypeid_changed event handler, change

markersArray[i].labelClass = 'gmapLabelsWhite';

to

markersArray[i].set("labelClass", 'gmapLabelsWhite');

and change

markersArray[i].labelClass = 'gmapLabelsBlk';

to

markersArray[i].set("labelClass", 'gmapLabelsBlk');

Note that you should always use the "set" function to change the values of 
properties, don't try to change them directly because there are often other 
actions that need to be performed. As the MarkerWithLabel Reference says: "To 
change any of these additional properties after the labeled marker has been 
created, call google.maps.Marker.set(propertyName, propertyValue)."

Original comment by garylitt...@gmail.com on 23 Aug 2011 at 5:57

GoogleCodeExporter commented 9 years ago
Aha. I changed the code as per your comment and it works now. Thanks much for 
the help. I did not see the 'set' method in the docs.

Original comment by robertln...@gmail.com on 23 Aug 2011 at 2:18