jesstelford / node-MarkerWithLabel

npm module of Google Map utility's Marker With Label
Apache License 2.0
38 stars 32 forks source link

index.js:56 Uncaught ReferenceError: module is not defined #10

Open lucasgerard opened 8 years ago

lucasgerard commented 8 years ago

Hi,

I've suddenly have issues with MarkerWithLabel, on the following URL: https://parisjetaide-tests.herokuapp.com/, with config:

    <script src="//maps.google.com/maps/api/js?v=3.23&sensor=false&libraries=geometry,places&key=<%= ENV['GOOGLE_MAPS_API_KEY'] %>" type="text/javascript"></script>
  <script src="//cdn.rawgit.com/mahnunchik/markerclustererplus/master/dist/markerclusterer.min.js"></script>
    <script src="https://cdn.rawgit.com/jesstelford/node-MarkerWithLabel/master/index.js"></script>

Any idea where does it come from?

Thanks!

jameelmoses commented 8 years ago

same issue ^

uguryilmaz commented 8 years ago

anyone could find a solution for this?

aTanCS commented 6 years ago

Justo remove

/**
 * @param {Object} gMapsApi The Google Maps API instance (usually `google.maps`)
 * @return {Function} The instantiable MarkerWithLabel class
 */
module.exports = function(gMapsApi) {

and

  return MarkerWithLabel;
}

replace all occurrences of gMapsApi with google.maps, use this code to init the map after markerwithlabel.js (renamed form index.js) is loaded because it needs loaded maps api and we use callback parameter in a googleapis load tag (the tag must be after init functions):


<script type="text/javascript">
function initMap() {
// you code to init a map: 
// var map = new google.maps.Map(...);
// var marker = new MarkerWithLabel(...);
// etc.
}

function init() {
      var file="markerwithlabel.js";
      var script = document.createElement("script");
      script.type = "text/javascript";
      script.src = file;
      script.onload = function(){
        initMap()
      };
      document.body.appendChild(script);
}
</script>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3&key=YOUR_KEY&libraries=places&callback=init"></script>