2012-03-08 57 views
0

如何「簡單的」從地理編碼 提取ADRESS值我的代碼看起來是這樣的:如何通過反向地理編碼ADRESS回變量

了一些事情之前....

geocoder.geocode({latLng: 'mylatlon'}, function(results, status) { 
    if (status == google.maps.GeocoderStatus.OK) { 
        if (results[0]) { 
        //alert(results[0].formatted_address); 
        thisadr=results[0].formatted_address; 
         }}});'; 

一些後...之類的東西如地圖標題:thisadr或infowindow.content(thisadr 沒了

它的工作原理雖然完美(要是我相信警報),但我不能讓thisadr VAR離開這裏

我花了大量的時間試圖尋找一個體面的直接的解決方案無濟於事

然後我有一個次要問題 我PHPbuild一個HTML表格在一個點上,我需要養活的信息窗口

所以搭配的是HTML表格與thisadr可變

到目前爲止並嚴重我的信息窗口看起來像

var contenuInfoBulle'.$camindex.' = \''.$phpbul.'\'; 

什麼,我想WOU LD是它顯示

var contenuInfoBulle'.$camindex.' = thisadr \''.$phpbul.'\'; 
+0

實時代碼的鏈接將非常有用。 – andresf 2012-03-08 06:02:50

+0

可能的重複[我將如何計算點之間的距離Google Maps Api V3](http://stackoverflow.com/questions/9608444/how-would-i-calculate-the-distance-between-the-points-谷歌,地圖,API-V3) – 2012-03-08 11:05:28

回答

0

我設法包括所有的東西需要的內部地址解析器請求,而創建一個索引功能,把它後來對每個索引標記回答我的問題

1/

echo 'function buildmarker'. ($camindex). '(location) {'; 
echo 'geocoder = new google.maps.Geocoder();'; 

echo "geocoder.geocode({'latLng': location}, function(results, status) {"; 
echo " rue='Adresse à déterminer';"; 
echo ' if (status == google.maps.GeocoderStatus.OK) {'; 
echo '  if (results[0]) {'; 
echo '   adress=results[0].formatted_address;'; 
echo "   elts=adress.split(',');"; 
echo '   rue=elts[0];'; 
echo '  }'; 

echo '  }'; 

echo 'var contenuInfoBulle = rue+\''.'<br>'.$phpbul.'\';'; 
echo 'var infoBulle = new google.maps.InfoWindow({ content: contenuInfoBulle });'; 
echo 'var thisicon = new google.maps.MarkerImage("../img /marker'.$coulgoog.$ajout.'.png",null, null, null, new google.maps.Size(25, 25));'; 
echo 'var optionscam= {position: location,map: macarte,title: "'.$camindex.'  '.$shortcam.'" ,icon: thisicon};'; 
echo 'var mark = new google.maps.Marker(optionscam);'; 
echo 'google.maps.event.addListener(mark, "click", function() {infoBulle.open(macarte, mark)});'; 
echo 'var optionsCercle = {center: location,map: macarte,radius: 20 ,strokeWeight: 0};'; 
echo 'var monCercle = new google.maps.Circle(optionsCercle);'; 


echo ' });'; 
echo '} ';   //func 

/////////////////////// 


echo "var cam". ($camindex). " = new google.maps.LatLng(".$myloc.");"; 
echo "buildmarker". ($camindex). "(cam".($camindex).");"; 

2 /通過混合JS/googmap變量和預製PHP/HTML內容

echo 'var contenuInfoBulle = rue+\''.'<br>'.$phpbul.'\';';