Google Maps MarkerLabel is not a feature

I am trying to figure out how to add Google Maps MarkerLabel .

I can get a standard marker for display, but when I try to add a label ! to the marker, I get google.maps.MarkerLabel is not a function .

 var marker = new google.maps.Marker({ animation: google.maps.Animation.DROP, label: new google.maps.MarkerLabel({ text: '!' }), map: myMap, position: myMapOptions.center }); 

I assume that I cannot create an instance of the new MarkerLabel object. What should I do to get an exclamation mark inside the marker.

+5
source share
1 answer

MarkerLabel is a specification of an anonymous object .

 var marker = new google.maps.Marker({ animation: google.maps.Animation.DROP, label: { text: '!' }, map: myMap, position: myMapOptions.center }); 

violin example

code snippet:

 var geocoder; var map; function initialize() { var map = new google.maps.Map( document.getElementById("map_canvas"), { center: new google.maps.LatLng(37.4419, -122.1419), zoom: 13, mapTypeId: google.maps.MapTypeId.ROADMAP }); var marker = new google.maps.Marker({ animation: google.maps.Animation.DROP, label: { text: '!' }, map: map, position: map.getCenter() }); } google.maps.event.addDomListener(window, "load", initialize); 
 html, body, #map_canvas { height: 100%; width: 100%; margin: 0px; padding: 0px } 
 <script src="https://maps.googleapis.com/maps/api/js"></script> <div id="map_canvas"></div> 
+9
source

All Articles