| |
|
Voir le sujet précédent :: Voir le sujet suivant
|
| Auteur |
Message |
| |
|
G4uthier Nouveau WRInaute
Inscrit le: 03 Juin 2008 Messages: 2
|
Posté le : Mar Juin 03, 2008 0:53 Sujet du message: Markers Google Map XML |
|
|
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: |
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
Inscrit le: 03 Juin 2008 Messages: 2
|
Posté le : Mar Juin 03, 2008 17:04 Sujet du message: Markers Google Map XML |
|
|
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? |
|
| |
|
 |
| |
|
|
|
|
Autres sujets de discussion :
|
|