Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
57
rated 0 times [  60] [ 3]  / answers: 1 / hits: 17985  / 10 Years ago, wed, august 6, 2014, 12:00:00

I am using this code this code to change label text of marker label in google map api. But this code not working.



var marker = new MarkerWithLabel({
position : latlng,
draggable : true,
raiseOnDrag : true,
map : map,
labelContent : textVal,
labelAnchor : new google.maps.Point(22, 0),
title : + textCount,
labelClass : someClass + textCount,
icon:{}
});
marker.setLabelContent(sdda);


please can anybody let me know what's wrong in my code?


More From » google-maps

 Answers
8

Try:



marker.set('labelContent', 'sdda');


Reading through the marker label source code, the MarkerLabel object extends from google.maps.Marker.



Whenever you call the .set() method on the MarkerLabel object, an event is raised which refreshes the marker.



So calling marker.set('labelContent', 'sdda'); will raise a 'labelcontent_changed' event, which in turn makes the marker set it's inner content this.setContent()



Here is an excerpt from the source code:



@class This class represents the optional parameter passed to the {@link MarkerWithLabel} constructor.
The properties available are the same as for google.maps.Marker with the addition of the properties listed below. To change any of these additional properties after the labeled
marker has been created, call google.maps.Marker.set(propertyName, propertyValue).


[#69882] Tuesday, August 5, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hailey

Total Points: 355
Total Questions: 91
Total Answers: 91

Location: India
Member since Wed, Aug 4, 2021
3 Years ago
;