Markers Google Map XML

Consultez la formation Google Maps, News, Images de WebRankInfo / Ranking Metrics

G4uthier
Nouveau WRInaute
Nouveau WRInaute
 
Messages: 2
Inscription: 3 Juin 2008

Markers Google Map XML

Message le Mar Juin 03, 2008 0:53

Bonjour,
voila mon probleme:
je comprends pas pourquoi mes markers cree ne contiennent que la variable address2 et de plus tous les pointeurs ont la meme valeur pour la variable address2...
Si quelqu'un voit pourquoi ca fonctionne pas je lui en serait infiniement reconnaissant...

Code: Tout sélectionner
var map;
var localSearch = new GlocalSearch();
var address2;
var address3;
var postcode;
var img;
var icon = new GIcon();

icon.image = "http://images.google.com/mapfiles/marker.png";
icon.iconSize = new GSize(20, 30);
icon.iconAnchor = new GPoint(6, 20);
icon.infoWindowAnchor = new GPoint(10, 34);


function usePointFromPostcode(postcode,callbackFunction) {
   
    localSearch.setSearchCompleteCallback(null,
        function() {
           
            if (localSearch.results[0])
            {       
                var resultLat = localSearch.results[0].lat;
                var resultLng = localSearch.results[0].lng;
                var point = new GLatLng(resultLat,resultLng);
                callbackFunction(point, address2, address3, postcode,img);
            }else{
                alert("Postcode not found!");
            }
        });   
       
    localSearch.execute(postcode + ", UK");
    }

//function placeMarkerAtPoint(point)
//{
//    var marker = new GMarker(point,icon);
//    map.addOverlay(marker);
//}

function setCenterToPoint(point)
{
    map.setCenter(point, 15);
    var marker = new GMarker(point,icon);
    map.addOverlay(marker);
    map.openInfoWindow(map.getCenter(),"<img src='http://localhost/Smart/images/icon_map.gif' />");
    }
   
function showPointLatLng(point)
{
    var Latitude = point.lat();
    var Longitude = point.lng();
   
    }

function mapLoad() {
    if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(54.622978,-2.592773), 5, G_NORMAL_MAP);
    }
}


GDownloadUrl("http://localhost/Smart/XmlGmap.php",function(data) {
  var xml = GXml.parse(data);
  var markers = xml.documentElement.getElementsByTagName("marker");
    for (var i = 0; i < markers.length; i++) {
        address2 = markers[i].getAttribute("address2");
        address3 = markers[i].getAttribute("address3");
        postcode = markers[i].getAttribute("postcode");
        img = markers[i].getAttribute("img1");
        alert("attention"+address2 );
        usePointFromPostcode(postcode,createMarker);
        //alert("valeur lon: "+Longitude);
        //alert("valeur la: "+Latitude);
        //var point = new GLatLng(Latitude,Longitude);
        //var marker = createMarker(point, address2, address3, postcode,img);
       
       
  }
});



function createMarker(point, address2, address3, postcode,img) {
  var marker = new GMarker(point, icon);
  alert(address2);
  alert(address3);
  alert(img);
  var html = "<b>" + address3 + "</b> <br/>" + address2;
  GEvent.addListener(marker, 'click', function() {
    marker.openInfoWindowHtml(html);
  });
map.addOverlay(marker);
  //return marker;
}





function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function addUnLoadEvent(func) {
    var oldonunload = window.onunload;
    if (typeof window.onunload != 'function') {
      window.onunload = func;
    } else {
      window.onunload = function() {
        oldonunload();
        func();
      }
    }
}

addLoadEvent(mapLoad);
addUnLoadEvent(GUnload);

G4uthier
Nouveau WRInaute
Nouveau WRInaute
 
Messages: 2
Inscription: 3 Juin 2008

Message le Mar Juin 03, 2008 17:04

j'ai ciblé mon probleme c'est mon appel de focntion qui deconne.
Lorsque j'appel "usePointFromPostcode(postcode,createMarker);" et bien dans la fonction "usePointFromPostcode(postcode,callbackFunction)" ,ma callbackfonction (createMarker) est appelé lorsque ma boucle qui parcours mon XML est fini. et c'est pour
ça que je me retrouve avec mon dernier enregistrement de ma table dans mon marqueur. Il crée donc tous les marqueur en fonction du dernier enregistrement de ma table...
Une idée, pourquoi il me fait ca? vous me comprenez?


Si vous avez aimé cette discussion, partagez-la sur vos réseaux sociaux préférés :

Formation recommandée sur ce thème :

Formation Google Maps, Google News et Google Images : apprenez comment optimiser le référencement de votre site pour la recherche universelle et notamment Google Maps, Google Actualités et Google Images. Formation animée par Olivier Duffez et Fabien Facériès, experts en référencement naturel.

Tous les détails sur le site Ranking Metrics : programme, prix, dates et lieux, inscription en ligne.

Lectures recommandées sur ce thème :



Qui est en ligne

Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 0 invités