Home > Web Front-end > JS Tutorial > Google Map V3 binding bubble window (infowindow) Dom event implementation code_javascript skills

Google Map V3 binding bubble window (infowindow) Dom event implementation code_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 17:35:12
Original
1292 people have browsed it

When debugging the function module, I found that the div added in the infowindow could not be bound to the event using any method. Depressing! I searched many methods on the Internet to no avail.
After thinking about it, I checked the official API and found that there is a domready event in the Events under google.maps.InfoWindow

Official explanation
This event is fired when the containing the InfoWindow's content is attached to the DOM. You may wish to monitor this event if you are building out your info window content dynamically.
I understand that the general meaning is InfoWindow The callback function after the dynamically added Dom element is completed.
JS is a single-threaded engine. Events can only be bound after the DOM is created. This should be very simple to understand!
Looking at the js code written by a colleague, there are a lot of delays such as setTimeout. I guess I didn’t understand the smooth execution of the script. I thought it would be executed after a delay of a few seconds. In fact, the problem is huge. Which scripts should be executed first and which ones should be executed later are all in order.
google.maps.event.addDomListener The code for listening to Dom element events provided by googleMap

:

Copy code The code is as follows:

google.maps.event.addListener(infowindow,"domready",function(){
var Cancel = document.getElementById(" Cancel");
var Ok=document.getElementById("Ok");
google.maps.event.addDomListener(Cancel,"click",function(){infowindow.close();});
google.maps.event.addDomListener(Ok,"click",function(){infowindow.close();});
});

Official API: https:// /developers.google.com/maps/documentation/javascript/3.exp/reference?hl=zh-cn
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template