title: google maps API polygon labels
body: <p>I am trying to put a label on a polygon drawn via the google maps api.</p>
  
  <p>the result of my getPolygons.php ajax call looks like this:</p>
  
  <pre><code>var triangleCoords = [
      {lat:38.88154,lng: -77.02880},
      {lat:38.83863,lng:-77.02760},
      {lat:38.83917,lng:-77.07292},
      {lat:38.84251,lng: -77.12098},
      {lat:38.86951,lng:-77.13575},
      {lat:38.88769, lng:-77.05404}
  ];
  </code></pre>
  
  <p>code:</p>
  
  <pre><code>$.ajax({
      type:"GET",
      url:"getPolygons.php",
      dataType:"json",
      success:function(result){
              $.each(result,function(e,i){
              var triangleCoords = [];
              var color = i.color;
              $.each(i.points,function(ee,ii){
                      var lat = parseFloat(ii.lat);
                      var lon = parseFloat(ii.lon);
                      triangleCoords.push({lat:lat,lng:lon});
              });
              var bermudaTriangle = new google.maps.Polygon({
                   paths: triangleCoords,
                   strokeColor: '#FF0000',
                   strokeOpacity: 0.8,
                   strokeWeight: 2,
                   fillColor: color, 
                   fillOpacity: 0.35
              });
              bermudaTriangle.setMap(map);
  
    var pos = new google.maps.LatLng(lat,lon);
    var marker = new MarkerWithLabel({
            position: pos,
            map: map,
            labelAnchor: new google.maps.Point(3, 30),
           labelClass: Sclass, // the CSS class for the label
            labelInBackground: false
            });
              });
       }
  </code></pre>
  
  <p>I have tried using markerswithlabel.js</p>
  
  <p>I include this script:</p>
  
  <pre><code> &lt;script src="https://maps.googleapis.com/maps/api/js?key=API_KEY&amp;signed_in=true&amp;libraries=drawing&amp;callback=initMap" defer&gt;&lt;/script&gt;
  </code></pre>
  
  <p>and the standard </p>
  
  <pre><code> &lt;script src='markerLabel.js'&gt;&lt;/script&gt;
  </code></pre>
  
  <p>but when i include markerLabel.js I get this error:</p>
  
  <pre><code> Uncaught ReferenceError: google is not defined
  </code></pre>
  
  <p>I am trying to do something like this:</p>
  
  <p><a href="https://i.stack.imgur.com/js1ui.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/js1ui.png" alt="My example"></a></p>