+ Antworten
Ergebnis 1 bis 2 von 2

Thema: GoogleMaps-Api findet einige Adressen nicht.

  1. #1
    TP-Senior mat81 macht alles soweit korrekt Avatar von mat81
    Registriert seit
    Jun 2005
    Ort
    Köln
    Beiträge
    241

    Question GoogleMaps-Api findet einige Adressen nicht.

    Hallo allerseits,

    die eingebaute GoogleApi läuft eigentlich ganz gut. Doch manchmal werden keine Adressen gefunden. Gebe ich den String genauso aber auf der maps.google.de ein, dann wird die Adrese gefunden.

    Die Funktion geocoder.getLatLng bekommt von mir einen Adress-String (z.B. "Zum Fischacker 5, 58898 Eslohe") und sollte die Koordinaten (var point) zurück geben. Dies klappt in einigen Fällen aber nicht.

    Nun fehlt mir der Ansatz. Sucht Google normalerweise die nächstmögliche Koordinate? Wenn ja, wie starte ich diesen Aufruf? Oder muss ich den String bearbeiten?

    Aber wie gesagt, oft klappts auch.

    Hier mal die wichtigste Funktion aus meinem js:

    Code:
    function showAddress(inf) {
    	var adr=inf['str']+', '+inf['plz']+' '+inf['ort'];
    	//var adr=inf['adress_encoded'];
    	var adr_show=inf['str']+', '+inf['plz']+' '+inf['ort'];
    	if(inf['logo']!="leer"){
    		var imglogo=new Image;
    		/*imglogo.src="images/"+inf['logo'];*/
    		imglogo.src=inf['logo'];
    	}
    	var info="";
    	info+='<div id="inWin" class="infoWindow" style="width: '+inf['infowin_x']+'px; height: 100px">';
    	info+="<div class='left' style='white-space:nowrap; width: 100px'><b>"+inf['company']+"</b><br />";
    	if(inf['denotation']!="leer"){info+=inf['denotation']+"<br />";}
    	info+=inf['str']+"<br />";
    	info+=inf['plz']+" "+inf['ort']+"<br />";
    	if(inf['tel']!="leer"){info+="Tel: "+inf['tel']+"<br />";}
    	if(inf['fax']!="leer"){info+="Fax: "+inf['fax']+"<br />";}
    	if(inf['email']!="leer"){
    		m=inf['email'];
    		mail="mailto:"+inf['email'];
    		info+='<a href="'+mail+'">'+m+'</a><br />';
    	}
    	if(inf['website']!="leer"){
    		u=inf['website'];
    		url="http://"+u;
    		info+='<a href="'+url+'" target="_blank">'+u+'</a>';
    	}
    	info+="</div>";
    	if(inf['logo']!="leer"){
    		i=inf['logo'];
    		var img='<div class="right"><div style="height: 20px; width="'+inf['logo_x']+'px">&nbsp;</div><img name="logobild" src='+imglogo.src+' width="'+inf['logo_x']+'px" height="'+inf['logo_y']+'px" onerror="this.style.display=\'none\'" /></div>';
    		info+=img;
    	}
    	info+='</div>';
    	var anfahrt="<div>"+googleRoute(adr);+"</div>";
    	var infoTabs = [	//tab width = 90 px			ä : &auml; : &#228; : E4 : 228 : ä(utf-8)
    		new GInfoWindowTab(" Händler ", info),
    		new GInfoWindowTab(" Anfahrt ", anfahrt)				
    	];
    	geocoder.getLatLng(
    		adr,
    		function(point) {
    			if (!point) {
    				var not=adr_show+" in GoogleMaps leider nicht gefunden";
    				//document.getElementById("mapD").style.display="none";
    				alert(not);
    			} else {			
    				map.setCenter(point, 12, G_HYBRID_MAP);
    				var marker = new GMarker(point, icon);
    					GEvent.addListener(marker, "click", function() {
        					marker.openInfoWindowTabsHtml(infoTabs);
    					});
    				map.addOverlay(marker);
    				map.addControl(new GLargeMapControl());
    				map.addControl(new GMapTypeControl());
    				marker.openInfoWindowTabsHtml(infoTabs);
    				if(inf['logo']!="leer"){
    					var lang=inWinSize(imglogo, inf['lang']);
    					document.getElementById('inWin').style.width=lang+"px";
    				}
    			}
    		}
    	);
    }
    Geändert von mat81 (13.03.2007 um 17:26 Uhr)

    The difference between theory and practice is
    that in theory there is no
    difference between theory and practice
    but in practice there is

  2. #2
    TP-Senior mat81 macht alles soweit korrekt Avatar von mat81
    Registriert seit
    Jun 2005
    Ort
    Köln
    Beiträge
    241

    Lösung

    Nun hab ich eine Lösung gefunden - scheint gut zu funktionieren. Bisher gabs noch keine Fehler.

    Und zwar hat das Plugin nur Probleme mit dem Ortsnamen gehabt, v.a. wenn der Stadtteil mit angegeben wurde. Deshalb hab ich den Suchstring von

    Code:
    var adr=inf['str']+', '+inf['plz']+' '+inf['ort'];
    auf

    Code:
    var adr=inf['str']+', '+inf['plz']+', Deutschland';
    geändert.

    Für länderübergreifende Anwendungen gilt dann natürlich:

    Code:
    var adr=inf['str']+', '+inf['plz']+', '+inf['staat'];

    Vielleicht konnte das auch anderen Helfen... ich bin froh, dass es jetzt Funktioniert.

    The difference between theory and practice is
    that in theory there is no
    difference between theory and practice
    but in practice there is

+ Antworten

Aktive Benutzer

Aktive Benutzer

Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)

     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51