
|

|

|

|
AJOUT D'UNE BULLE D'INFORMATION (SANS CODE HTML)
La propriété "openInfoWindow" (bulle d'info) ajoute une bulle pouvant contenir un texte (brute sans code HTML)
<html>
<head>
<title>Application Google Maps : Ajout d'une bulle d'information</title>
<script src="http://maps.google.com/maps?file=api&v=2&key=
ABQIAAAAFw0lDRKsdCra15LPvIxvehS3Kl_ZRrzIrsFqDz8GBXIeW1O52xQh3P31Xg2eTvqFRAyuOMY4dQrRQw"
type="text/javascript"></script>
<script type="text/javascript">//<![CDATA[
function load()
{
if (GBrowserIsCompatible())
{
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(48.85929404029, 2.341461181640), 12);
// "point" correspond aux coordonnées du marker
var point = new GLatLng(48.85846111697847, 2.2944045066833496);
// Affichage de la bulle d'information
map.openInfoWindowHtml(point,"Tour Eiffel");
}
}
//]]></script>
</head>
<body onload="load()" onunload="GUnload()">
<div id="map" style="width: 500px; height: 300px"></div>
</body>
</html>
|
Explications :
Initialisation de la variable "point" qui contiendra les coordonnées longitude/latitude. Dans l'exemple les coordonnées de la Tour Eiffel.
Pour ajouter la bulle, mise en oeuvre de la méthode "openInfoWindow" (Ouverture fenêtre d'info) avec l'attribut "GMarker(point)" et le texte à afficher dans la bulle.
Cette méthode ne permet que du texte brute sans balise HTML !
Résultat :
AJOUT D'UNE BULLE D'INFORMATION (AVEC CODE HTML)
La propriété "openInfoWindow" (bulle d'info) ajoute une bulle pouvant contenir un texte (brute sans code HTML)
<html>
<head>
<title>Application Google Maps : Ajout d'une bulle d'information</title>
<script src="http://maps.google.com/maps?file=api&v=2&key=
ABQIAAAAFw0lDRKsdCra15LPvIxvehS3Kl_ZRrzIrsFqDz8GBXIeW1O52xQh3P31Xg2eTvqFRAyuOMY4dQrRQw"
type="text/javascript"></script>
<script type="text/javascript">//<![CDATA[
function load()
{
if (GBrowserIsCompatible())
{
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(48.85929404029, 2.341461181640), 12);
// "point" correspond aux coordonnées du marker
var point = new GLatLng(48.85846111697847, 2.2944045066833496);
// Affichage de la bulle d'information
map.openInfoWindowHtml(point,
"<table><tr><td><img src=images/TourEiffel width=120 height=109></td><td>Tour Eiffel</td></tr></table>");
}
}
//]]></script>
</head>
<body onload="load()" onunload="GUnload()">
<div id="map" style="width: 500px; height: 300px"></div>
</body>
</html>
|
Explications :
Initialisation de la variable "point" qui contiendra les coordonnées longitude/latitude. Dans l'exemple les coordonnées de la Tour Eiffel.
Pour ajouter la bulle, mise en oeuvre de la méthode "openInfoWindowHtml" (Ouverture fenêtre d'info avec HTML) avec l'attribut "GMarker(point)" et le texte (avec possibilité d'inclure du code HTML) à afficher dans la bulle.
Cette méthode ne permet d'insérer des balises HTML !
Résultat :

|

|
|
|