Comments (1)
This issue is directly related to the placement of the domready
event trigger in the infobubble.js code.
Unfortunately it's currently located in the updateContent_()
function, which is called by open_()
, before setMap()
is called - which means that domready
is fired BEFORE the infoBubble is added to the DOM.
It's not possible to simply add the domready
trigger after the setMap()
call in the open_()
function because setMap()
is asynchronous... and the setMap()
function doesn't have a specific callback.
However, according to the documentation for OverlayView (which is what is being used by this plugin)
https://developers.google.com/maps/documentation/javascript/reference?csw=1#OverlayView
the setMap()
function calls the onAdd()
function once AFTER setMap()
is called with a valid map
onAdd(): Implement this method to initialize the overlay DOM elements. This method is called once after setMap() is called with a valid map. At this point, panes and projection will have been initialized.
and more simply:
In the onAdd() method, you should create DOM objects and append them as children of the panes.
Therefore we should fire the domready
event within the onAdd()
function, after the infoBubble
is appended to the map panes:
/**
* On Adding the InfoBubble to a map
* Implementing the OverlayView interface
*/
InfoBubble.prototype.onAdd = function() {
if (!this.bubble_) {
this.buildDom_();
}
this.addEvents_();
var panes = this.getPanes();
if (panes) {
panes.floatPane.appendChild(this.bubble_);
panes.floatShadow.appendChild(this.bubbleShadow_);
}
google.maps.event.trigger(this, 'domready'); // infobubble has now been added to DOM so we can fire `domready`
};
PR #13 fixes this issue.
JS Fiddle here with updated code (see line 910 in the javascript window for new domready
placement)
http://jsfiddle.net/goredwards/7r96we66/
note that I've added timestamps in the jsfiddle at the old domready
call and the correct (updated) domready
call - you'll see them in the console.log
- it comes to about 20ms on my system (it will vary with computer speed)
- it shows that the old domready was indeed firing prior to the
infoBubble
being appended to the panes - this gives an idea of the minimum
setTimeout
you'd need to put around any functions within adomready
call if you want to use the original code without the fix - see http://jsfiddle.net/goredwards/xeL7dxye/
from js-info-bubble.
Related Issues (20)
- autopan centres clicked marker rather than moving map just enough for infobubble to be visible HOT 2
- Can the infobubble be positioned below the marker? HOT 2
- Add bower support HOT 11
- Add package.json HOT 6
- Issue in tabs height calculation
- Gutter parameter
- Google Maps API v3 and Fusion Table V2 map app takes huge time to load on Chrome
- Internet Explorer Edge Issue
- Sometimes setContent fails
- InfoBubble is not a constructor HOT 1
- close button should have a css class HOT 1
- IE Edge Performance Issue when creating InfoBubble HOT 1
- how can i add box-shadow in InfoBubble css ?
- How do I add this library to my angular2 app? HOT 3
- Improve render performance
- Add additional CSS to infoBubble?
- no way to change default animation HOT 1
- maxWidth is not working HOT 1
- Arrow position (left, right, top, etc)
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-info-bubble.