I want to attach labels to my markers, using the markerwithlabel.js package (http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerwithlabel/1.1.9/). I put the package link in the document header, and added the label properties in my addMarker function. I have no idea why the labels do not appear, since before I added the label properties everything worked. Am I missing something?
In the header:
<script src="http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerwithlabel/1.1.9/src/markerwithlabel.js" type="text/javascript"></script>
Here I create the markers:
//iterate through marker data and assign values to variables
for (i = 0; i < markerData.length; i++) {
var pos = new google.maps.LatLng(markerData[i][1], markerData[i][2]);
var title = markerData[i][0];
var category = markerData[i][3];
var new_marker = addMarker(pos, title, category);
arrMarkers.push(new_marker);
new_marker.setVisible(false);
}
//create marker based on the variables
function addMarker (pos, title, category) {
var marker = new google.maps.MarkerWithLabel({
map: map,
position: pos,
icon: "mapIcons/marker_"+markerData[i][4]+".png",
category: category,
labelContent: "test",
labelAnchor: new google.maps.Point(22, 0),
labelClass: "labels", // the CSS class for the label
labelStyle: {opacity: 0.75},
});
infoBubble = new InfoBubble({
maxWidth: 300,
borderRadius: 10,
borderWidth: 1,
borderColor: '#2c2c2c',
shadowStyle: 1
});
var infoWindow = new google.maps.InfoWindow;
var info = 'Functie: ' + '<b>' + markerData[i][0] + "</b>" + '<br>' + 'Eigenschappen: ' + '<b>' + markerData[i][6] + "</b>" ; //html inside InfoWindow
//var video = "<div>" + '<iframe width="420" height="315" src="//www.youtube.com/embed/4gMH0V4L4A4">' + '</iframe>' + "</div>"; //html inside InfoWindow
var video = '<iframe title="YouTube video player" class="youtube-player" type="text/html" width="250" height="188" src="http://www.youtube.com/embed/UmFjNiiVk9w?rel=0" frameborder="0"></iframe>';
//var video = '<iframe title="YouTube video player" class="youtube-player" type="text/html" width="200" height="180" src="//www.youtube.com/embed/4gMH0V4L4A4?rel=0" frameborder="0"></iframe>'
//var video = '<iframe width="420" height="315" src="//www.youtube.com/embed/S_9CSFeO9sM?rel=0" frameborder="0" allowfullscreen></iframe>'
var media = "<b>" + 'Laatste foto, ontvangen op 15:33 9-7-2013' + "</b>" + '<img src="others/schiphol_marechaussee.jpg" alt="laatste foto">' ; //html inside InfoWindow
var contact = ' <form><textarea rows="10" cols="30">Typ hier je bericht</textarea>' + '<input type="reset" value="Verstuur"></form>'; //html inside InfoWindow
if (markerData[i][5] == 'info') {
bindInfoWindowInfo(marker, map, infoBubble, info);
infoBubble.addTab('Info', info);
infoBubble.addTab('Contact', contact);
infoBubble.addTab('Media', media);
};
if (markerData[i][5] == 'video') {
bindInfoWindowVideo(marker, map, infoBubble, video);
infoBubble.addTab('Video', video);
};
return marker;
}
Upon clicking a checkbox, the markers appear (that's why its setVisible is false).
When I run your code I get this error in the javascript console:
Error: google.maps.MarkerWithLabel is not a constructor
because MarkerWithLabel is not part of the Google Maps API v3. Change the constructor to:
var marker = new MarkerWithLabel({
map: map,
...