Bonsoir, je viens vous demander de l'aide car je tourne en rond pour mettre en place l'api google map sur un site
J'ai fait :
function carte($VILLE,$CP,$ZOOM)
{
?>
<body onload="load();boucle();" onunload="GUnload()">
<form action="#" onsubmit="showLocation(); return false;">
<input type="hidden" name="q" value="" class="address_input" size="40" />
</form>
<div id="map" style="width: 550px; height: 450px"></div>
<div id="side_bar"></div>
</body>
<script
src="http://maps.google.com/maps?file=api&v=2.x&key=......."
type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
var map;
var geocoder;
function load() {
map = new GMap2(document.getElementById("map"));
//map.addControl(new GSmallMapControl());
map.addControl(new GLargeMapControl());
map.setCenter(new GLatLng( 43.907787,2), 5);
geocoder = new GClientGeocoder();
}
function addAddressToMap(response) {
if (!response || response.Status.code != 200) {
alert("Désolé, mais cette adresse n'a pas été trouvée");
} else {
place = response.Placemark[0];
point = new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);
//map.setCenter(new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]), 14);
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function() {
<?php $test1 = "en test";?>
marker.openInfoWindowHtml("<?php echo $test1;?><br />test suite");
});
map.addOverlay(marker);
}
}
function showLocation() {
var address = document.forms[0].q.value;
geocoder.getLocations(address, addAddressToMap);
}
function findLocation(address) {
document.forms[0].q.value = address;
showLocation();
}
function boucle()
{
findLocation('<?php echo $VILLE; if(strlen($CP)>"2") echo " ".$CP;?>');
}
//]]>
</script>
<?php
}
De cette facon, j'arrive a afficher une ville. Maintenant, j'arrive pas
en afficher plusieurs que je ressort de la base de données ....
Auriez vous une idée ?,
merci