J'essaie d'afficher l'InfoWindow au bon endroit sur une intégration Google Maps sur laquelle je travaille (juste au-dessus du coin en haut à droite/en haut à gauche d'une image). Chaque fois que j'essaye d'ajuster le "infoWindowAnchor" il ne semble pas fonctionner? Cependant, le "iconAnchor" semble fonctionner comme prévu. Je me demande si quelqu'un a déjà rencontré un scénario similaire auparavant? J'utilise une icône personnalisée, mais même lorsque je reviens aux icônes standard fournies par Google, l'infoWindow semble ne pas s'afficher correctement (la queue est centrée sur l'icône au lieu d'être placée dans sa position en haut à droite).Google Maps API infoWindowAnchor ne fonctionne pas?
Voici le code que j'utilise pour que tout fonctionne. Les bits importants sont ici, mais j'ai supprimé certaines des autres fonctions qui pourraient vous gêner lors du diagnostic.
$(document).ready(function() {
var centerLatitude = 37.782112;
var centerLongitude = -122.419281;
var sanFran = new GLatLng(centerLatitude, centerLongitude);
var startZoom = 12;
var map;
var icon;
// Creates a default icon using our tuberent image
var myIcon = new GIcon();
myIcon.image = baseurl + 'my/imageFolder/markerFolder/image.png';
myIcon.shadow = baseurl + 'my/imageFolder/markerFolder/shadow.png';
myIcon.iconSize = new GSize(25,25);
myIcon.shadowSize = new GSize(38,25);
myIcon.iconAnchor = new GPoint(13,25);
myIcon.infoWindowAnchor = new GPoint(13,0);
myIcon.printImage = baseurl + 'my/imageFolder/markerFolder/printImage.gif';
myIcon.mozPrintImage = baseurl + 'my/imageFolder/markerFolder/mozPrintImage.gif';
myIcon.printShadow = baseurl + 'my/imageFolder/markerFolder/printShadow.gif';
myIcon.transparent = baseurl + 'my/imageFolder/markerFolder/transparent.png';
myIcon.imageMap = [22,0,22,1,22,2,21,3,21,4,21,5,21,6,21,7,23,8,24,9,24,10,22,11,22,12,22,13,22,14,22,15,22,16,22,17,22,18,22,19,22,20,22,21,22,22,22,23,22,24,2,24,1,23,1,22,1,21,1,20,1,19,1,18,1,17,1,16,1,15,1,14,1,13,1,12,1,11,0,10,0,9,1,8,3,7,4,6,5,5,7,4,8,3,9,2,10,1,11,0];
map = new GMap2(document.getElementById('map'));
map.addControl(new GMapTypeControl());
map.addControl(new GLargeMapControl3D());
map.setCenter(sanFran, startZoom);
/* Some Random Code and Functions here .... */
var point = new GLatLng(location.lat, location.lng);
var marker = new GMarker(point, myIcon);
map.addOverlay(marker);
/* Some Random Code and Functions here .... */
GEvent.addListener(marker, "click", function(){
var randomText = "Just some random test text";
var myHtml = "<b>#" + location.id + "</b><br/>" + location.neighborhood + "<br/>" + randomText;
map.openInfoWindowHtml(point, myHtml);
});
});
$(document.body).unload(function() {
if (GBrowserIsCompatible()) {
GUnload();
}
});
Merci pour vos commentaires. J'ai réellement réalisé ce que je faisais mal. Quand j'appelais la méthode openInfoWindowHtml, je l'appelais comme suit: map.openInfoWindowHtml (point, myHtml); au lieu de cela: marker.openInfoWindowHtml (myHtml); – dnyce