Code for binding a bubble window (infowindow) Dom event to Google Map V3

Source: Internet
Author: User

When debugging the function module, I found that no method can be used to bind the div added in infowindow for event processing. Depressed! It is useless to search the Internet for many methods,
Later, I checked the official API and found a domready event in Events under google. maps. InfoWindow.

Official explanation:
This event is fired when the ining 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.
What I understand is the callback function after the Dom elements dynamically added in InfoWindow are completed.
Js is a single-threaded engine. events can be bound only after DOM is created. It should be easy to understand!
Looking at the js code written by my colleagues, the latency of many setTimeout operations is estimated to be several seconds before the execution of the script is smooth. In fact, the problem is very high. Which scripts need to be executed first and which need to be executed later are ordered.
Google. maps. event. addDomListener events provided by googleMap to listen to Dom elements

Code on
:Copy codeThe 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.