[Javascript] Google map compatibilité FF et IE :s

WRInaute occasionnel
Bonjour à vous, je fais appel aux experts débugger du js :(

Démoralisé complet j'essaye de faire une google map avec api pour des clients, en gros il entre leur adresse, cp et ville dans un form qui ai enregistré dans une bdd, puis je récupere mes données directe sur la google map...

Tout marche avec Firefox, ca marche meme particulierement bien, mais rien sur IE :s il y a une erreur sur ce script je pense. Si quelqu'un pouvait m'aider svp :(

Code:
// JavaScript Document
//setTimeout('initData()', 500);

var map;
var geocoder;
var centerLatitude = 47.389285;
var centerLongitude = 0.689049; 
var startZoom = 9;
var xmlhttp;
var markers;

var iconeVert = new GIcon();
iconeVert.image = "images/vert.png";
iconeVert.shadow = "images/ombre.png";
iconeVert.iconSize = new GSize(12, 20);
iconeVert.shadowSize = new GSize(22, 20);
iconeVert.iconAnchor = new GPoint(6, 20);
iconeVert.infoWindowAnchor = new GPoint(5, 1);

var deselectCurrent = function() {};

function searchPoint(queri) {
var queries = "" + queri;
var s = document.createElement( "script" );
s.src="http://www.localsearchmaps.com/geo/" + queries + "&cb=mapZoom";
s.type = "text/javascript";
document.getElementsByTagName( "head" )[0].appendChild(s);
}


function initializePoint(pointData) {
	var point = new GLatLng(pointData.latitude, pointData.longitude);
	var marker = new GMarker(point,{icon: iconeVert, title: pointData.nom});
	var listItem = document.createElement('li');
	var listItemLink = listItem.appendChild(document.createElement('a'));
	listItemLink.href = "#";
	listItemLink.onmouseover = function() { marker.setImage("images/rouge.png");}
	listItemLink.onmouseout = function() { marker.setImage("images/vert.png");}
	listItemLink.innerHTML = '<strong>' + pointData.nom + ' - ' + pointData.identifiant +' </strong><span>' + pointData.ville+ '</span>';
	
	var focusPoint = function() {
		deselectCurrent();
		listItem.className = 'current';
		marker.setImage("images/rouge.png");
		deselectCurrent = function() { listItem.className = ''; marker.setImage("images/vert.png");}
		marker.openInfoWindowHtml(pointData.nom+' - BAL : '+pointData.identifiant+' - '+pointData.ville);
		map.panTo(point);
		return false;
	}
	
	listItemLink.onclick = focusPoint;
	GEvent.addListener(marker, 'click', focusPoint);	
	GEvent.addListener(marker, 'mouseover', function() { marker.setImage("images/rouge.png"); });
	GEvent.addListener(marker, 'mouseout', function() { marker.setImage("images/vert.png"); });
	GEvent.addListener(marker, 'infowindowclose', function(){marker.setImage("images/vert.png");});	
	document.getElementById('sidebar-list').appendChild(listItem);
	map.addOverlay(marker);
}

function windowHeight() {
	// Standard browsers (Mozilla, Safari, etc.)
	if (self.innerHeight)
		return self.innerHeight;
	// IE 6
	if (document.documentElement && document.documentElement.clientHeight)
		return document.documentElement.clientHeight;
	// IE 5
	if (document.body)
		return document.body.clientHeight;
	// Just in case.
	return 0;
}

function handleResize() {
	var height = windowHeight()-20;
	document.getElementById('map').style.height = height + 'px';
	document.getElementById('sidebar').style.height = height + 'px';
}

function changeBodyClass(from, to) {
	document.body.className = document.body.className.replace(from, to);
	return false;
}

function setAlertText(str) {
	document.getElementById('alert').innerHTML = '<p>' + str + '</p>';
}

function initData() {
	map = new GMap(document.getElementById("map"),{mapTypes:[G_PHYSICAL_MAP,G_NORMAL_MAP,G_SATELLITE_MAP,G_HYBRID_MAP]});
	map.addControl(new GMapTypeControl());
	map.addControl(new GLargeMapControl());
	map.addControl(new GOverviewMapControl(new GSize(200,180)));
	map.setCenter(new GLatLng(centerLatitude, centerLongitude), startZoom);
	geocoder = new GClientGeocoder();
	var bounds = new GLatLngBounds();
	for(id in markers) {
		initializePoint(markers[id]);
		bounds.extend(new GLatLng(markers[id].latitude, markers[id].longitude));
	}
	map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
	changeBodyClass('loading', 'standby');
	var divt = document.createElement('div');
	divt.style.margin = "0";
	divt.style.padding = "0";
	divt.style.textAlign = "center";
	divt.style.backgroundColor = "#FFF9DD";
	divt.style.borderTop = "1px solid #dddddd";
	divt.innerHTML = "";
	var linkt = divt.appendChild(document.createElement('a'));
	
	document.getElementById('sidebar').appendChild(divt);
}

function init() {
		handleResize();
		xmlhttp = GXmlHttp.create();
		xmlhttp.open('GET', 'js/json.php', true);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4) {
				if (xmlhttp.status != 200) 
					setAlertText('Impossible d acceder aux donnees de la carte.');
				else
				{
					var responseText = xmlhttp.responseText;
					markers = eval(responseText);
					if (!markers)
						setAlertText('Erreur de donnees.');
					else
						initData();
				}
		   }
		}
		xmlhttp.send(null);
		
}


//setTimeout('initData()', 5000);    
window.onresize = handleResize;
window.onload = init;
window.onunload = GUnload;

Pour infos, vous pouvez voir la google map ici : http://www.secteur18.com/fr/game/affichage.htm , mes infos récupéré pour la bdd sont sur ce fichier http://www.secteur18.com/fr/game/js/json.php

:)
 
WRInaute occasionnel
Bon je crois que j'ai trouver le truc, enfaite ca viendrait de la fonction EVAL de javascript

Code:
					markers = eval(responseText);

Mais comment contourner ca ?
 
Discussions similaires
Haut