Gianluca Ghettini
Gianluca Ghettini

Reputation: 11648

MarkerWIthLabel maps library: this.setValue is not a function

I have a JavaScript application and I'm trying to use the MarkerWithLabel library to add CSS styling to markers on my map. On my CSS file I've added the labels class:

 .labels {
   color: red;
   background-color: white;
   font-size: 10px;
   font-weight: bold;
   text-align: center;
   width: 60px;     
   border: 2px solid black;
   white-space: nowrap;
 } 

and, on the JavaScript code I'm using the MarkerWithLabel class instead of the default google.maps.Marker

       var marker = new MarkerWithLabel({
           position: new google.maps.LatLng(lat, lon),
           draggable: false,
           raiseOnDrag: false,
           map: map,
           labelContent: "my label text",
           labelAnchor: new google.maps.Point(22, 0),
           labelClass: "labels",
           labelStyle: {opacity: 1.0}
        });     

As soon as I use the new class I get this error:

TypeError: this.setValues is not a function at MarkerWithLabel.gf (js?key=MYGOOGLEKEY&callback=loadMapsApiEnd&libraries=places&_=1544699657828

I have no idea what this file is: MarkerWithLabel.gf

I've included this .js file: https://github.com/googlemaps/v3-utility-library/blob/master/markerwithlabel/src/markerwithlabel.js

Upvotes: 0

Views: 1358

Answers (1)

Gianluca Ghettini
Gianluca Ghettini

Reputation: 11648

I just found the problem, I had to include MarkerWithLabel.js after the Google maps API library

Upvotes: 5

Related Questions