Hi,
If possible, I would like to dynamically modify the CSS width property
to reflect the width of the labelText string.
For example, the CSS set width property is 40px. The text string
property is 100px. Change width = 100px
<style type="text/css">
.labels {
color: red;
background-color: white;
font-family: "Lucida Grande", "Arial", sans-serif;
font-size: 10px;
font-weight: bold;
text-align: center;
width: 40px;
border: 2px solid black;
white-space: nowrap;
}
</style>
function createLabeledMarker(lat, lon, labelText, infoText,
iconURI) {
var html = "<span class=\"infoWindowContent\">" + infoText +
"</span>";
var thisMarker = new MarkerWithLabel({
map: map,
position: new google.maps.LatLng(lat, lon),
title: '', //mouseover popup label
icon: iconURI,
draggable: false,
raiseOnDrag: false,
labelContent: labelText,
labelVisible: true,
labelAnchor: new google.maps.Point(22, 0),
labelClass: "labels", // the CSS class for the label
labelStyle: { opacity: 1.00 }
});
changeWidth(labelText.length);
bindInfoWindow(thisMarker, map, infoWindow, html);
gmarkers_list.push(thisMarker);
}
function changeWidth(newWidth) {
var elem = document.getElementById("labels");
elem.width = newWidth;
}
I've tried this, but no joy.
appreciate any assistance.
Reference link:
http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerwithlabel/1.1.5/examples/basic.html
thanks.