I added markers onto my map via this function.
markers: an array of Marker objects
location: a LatLng object
myMarkerTitle: the desired title for my marker
// adds new markers to the map.
function addAMarker(location, myMarkerTitle) {
newMarker = new google.maps.Marker({
position: location,
map: map
});
newMarker.setTitle(myMarkerTitle);
markers.push(newMarker);
}
It adds markers on the map, but the titles I assigned to the markers do not show. Why?
In the end, I want a map with markers scattered about with titles above them. When a client hovers over and clicks on a marker, more details also surface. Thank you.
From what I understood, you want a tooltip visible at all times. There’s the InfoBox Utility library that can create something like that. It’s very flexible, which also means there are a lot of options to set. An annoyance, for example, is if the text gets too long it flows outside the box (so the width would need to be set dynamically).
Doc: http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/examples.html
Download: http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/src/
See the screenshot, if it’s what you want, download infobox_packed.js and try the code below.