in pratica bisogna prima caricare dinamicamente ll div con l'id che lo scritp della funzione della mappa cerca (io ho usato map )...poi fare le chiamate agli script delle mappe,in modo che nella pagina sia presente tale id.
ecco lo script completo (per le chimata ajax ho usato la libreria zXml)
Codice PHP:
<script type="text/javascript">
var map = null;
var geocoder = null;
function load() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(41.91633, 12.482185), 5);
geocoder = new GClientGeocoder();
}
}
function showAddress(address) {
if (geocoder) {
geocoder.getLatLng(
address,
function(point) {
if (!point) {
alert(address + " not found");
} else {
map.setCenter(point, 16);
var marker = new GMarker(point);
map.addOverlay(marker);
marker.openInfoWindowHtml(address);
}
}
);
}
}
function request(nomeFile){
var id = document.getElementById("ajax");
var oXHR = zXmlHttp.createRequest();
oXHR.open("GET",nomeFile,true);
oXHR.onreadystatechange = function(){
if(oXHR.readyState == 4){
if(oXHR.status == 200 || oXHR.status == 304){
id.innerHTML = oXHR.responseText;
load();
showAddress('Via Pinco Pallino, 14, ROMA Italy');
}
}
};
oXHR.send(null);
return false;
}
</script>