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