Git Product home page Git Product logo

Comments (7)

broady avatar broady commented on May 28, 2024

I think we can just add

this.prototype = new google.maps.OverlayView; to the constructor.

@brendankenny wdyt?

from js-map-label.

broady avatar broady commented on May 28, 2024

Wait no, that would override all of the other methods we've added already. Hm.

from js-map-label.

JimBobSquarePants avatar JimBobSquarePants commented on May 28, 2024

Assigning the prototype like that would happen too late. When you assign the prototype within the constructor, it's assigned after first instantiation. Copying the OverlayView properties to extend MapLabel is the simplest method I can think of.

from js-map-label.

jborden avatar jborden commented on May 28, 2024

JimBobSquarePants: Your solution works, thanks. Perhaps open a pull request?

from js-map-label.

algodave avatar algodave commented on May 28, 2024

I'm experiencing the same issue as @JimBobSquarePants
I need to load maps APIs asynchronously because I'm passing API key to it, which is a configuration param of my app.
👍 for a pull request.

from js-map-label.

Bostermann avatar Bostermann commented on May 28, 2024

I experienced the same error.
I loaded GoogleMapApi asynchronously with a callback function and an attribute defer.
A script dependant on GoogleMapApi was loaded without async and defer. This caused the error in the customized OverlayView: this.setMap is no function.
Adding the defer attribute to the script tag dependent of GoogleMapsApi solved the issue.
The main parts of my code:

    <script async defer type="text/javascript"
    src="https://maps.google.com/maps/api/js?language=de&amp;key=MyKey&amp;callback=initMap">
     </script>
    <script type="text/javascript" src="lib/routeMain.js" ></script>
    <script defer type="text/javascript" src="lib/markermanager.js"></script>

In routeMain.js:

function initMap() {
if (typeof console !== 'undefined' && typeof console.log !== 'undefined') {
console.log('GoogleMapsApi loaded.');
}
}
document.addEventListener('DOMContentLoaded', function () {
if (typeof console !== 'undefined' && typeof console.log !== 'undefined') {
console.log('+++main page was loaded.');
}
initialize();
}, false);
var map;
function initialize() {
var latlng = new google.maps.LatLng(51.31893, 9.49601); //Kassel, Germany
var myOptions = {
zoom: 7,
center: latlng,
mapTypeControl: true
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}

from js-map-label.

ankesh4040 avatar ankesh4040 commented on May 28, 2024

Any solution on this issue.
I tried using fhackenberger 's edited code. But now I am getting error :- Uncaught ReferenceError: MapLabel is not defined

from js-map-label.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.