Comments (7)
I think we can just add
this.prototype = new google.maps.OverlayView;
to the constructor.
@brendankenny wdyt?
from js-map-label.
Wait no, that would override all of the other methods we've added already. Hm.
from js-map-label.
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.
JimBobSquarePants: Your solution works, thanks. Perhaps open a pull request?
from js-map-label.
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.
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&key=MyKey&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.
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)
- how to change icon with js-map-label
- This dependency was not found
- How to remove label from map
- Text doesn't always fit into the canvas
- Support Retina Displays HOT 5
- How do I position the label above my marker? HOT 4
- Rotate Map Label HOT 1
- What are the differences between git repository and googlecode repository? HOT 1
- Multiline / Wrap Text Support HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from js-map-label.