Google Maps JS V3 API tutorial (3)--Create Infowindow

Source: Internet
Author: User

Original address

We learned about the creation of maps and markers in the front. So today we're going to learn how to display a window on a map (Infowindow)

The Infowindow constructor is:Infowindow (opts?:infowindowoptions).

The infowindowoptions Object Specifies the initialization parameters that are used to display the information window.   

Infowindowoptions Object Properties:

content: contains a text string or displays a DOM node in the Information window.

Pixeloffset: represents the position offset of the information window.

The location (latitude and longitude) of the Position:infowindow display.

maxWidth: Specifies the maximum width of the pixel information window.

Now let's create a Infowindow:

<!    DOCTYPE html>Add a listener function for marker to the Click event (that is, the point is marker after the Infowindow is displayed) Marker.addlistener (' click ', Function () {Infowindow.open        (map, marker);      }); } </script> <script Async defer src= "Https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callba Ck=initmap "> </script> </body>

The above is the code to create Infowindow, when we click on the map marker, Infowindow is displayed!

When we want to change the content of Infowindow, we can use "infowindow.setcontent" ("Content to be changed"); " To change the content of Infowindow, and we can also use infowindow.getcontent () to get Infowindow content.

Google Maps JS V3 API tutorial (3)--Create Infowindow

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.