goole map api 動態抓取地址 - Google

Leila avatar
By Leila
at 2009-10-27T08:33

Table of Contents

我是要從網頁中資料庫裡的地址去讀出google map位址

如果是在同一個網頁上執行,就沒問題

如果新開啟網頁來顯示地圖,會有開啟後,沒執行js的函數

--------------(這是準備開啟電子地圖的網頁)
<input type="hidden" name="Addr" value="<?php echo $row_hous\
e_qry_2['Addr']; ?>"/>
(用hidden來讀取Addr的資料)
<input name="button" type="button" value="Search" onclick="j\
avascript:
window.open('myp.php?Addr=<? echo $row_house_qry_2['Addr'];?\
>'addressGps();)
" /> (重點在於我不知怎麼開啟新頁後,直接讀取 addressGps();)


-------------(這是js)
function load() {
if (GBrowserIsCompatible()) {
myMap = new GMap2(document.getElementById("my_map"));
var myLatLng = new GLatLng(25.04763902653048, 121.517157554626\
46);
myMap.setCenter(myLatLng, 15);
myMap.addControl(new GLargeMapControl());
document.getElementById('inLatLng').value = myLatLng.toString();
document.getElementById('inLat').value = myLatLng.lat();
document.getElementById('inLng').value = myLatLng.lng();

myMarker = new GMarker( myLatLng );
myMap.addOverlay( myMarker );
}
}

function addressGps() {
var myGeocoder = new GClientGeocoder();
var address = document.getElementById('address').value;
myGeocoder.getLatLng(address, function getRequest( point ){
if(!point){
alert('地址錯誤');
}else{
myMap.panTo( point );
myMarker.setLatLng(point);
document.getElementById('inLatLng').value = point.toString();
document.getElementById('inLat').value = point.lat();
document.getElementById('inLng').value = point.lng();
}
});
}

//]]>
</script>

--
Tags: Google

All Comments

我不要翻譯~

Adele avatar
By Adele
at 2009-10-27T00:53
我裝了search的toolbar之後 翻譯的也會自己跑出來 請問有辦法單獨移除翻譯嗎? - ...

用了兩三天的google wave

Isla avatar
By Isla
at 2009-10-27T00:31
前兩天收到google丟給我的邀請函就開了wave來用... 感想很簡單 要拿來當作企業內部開會用的服務 只要能打敗office那wave其實很好用 但是要拿來當社群服務 那這個進入門檻比twitter高100倍的twitter加強版是死路一條... -- ★MxDxCxi 感冒嗎 To MxD ...

google talk壞了?

Candice avatar
By Candice
at 2009-10-26T22:58
※ 引述《rockmanray (禿驢)》之銘言: : 用firefox來開g-talk : 可是出現404 not found : 有人會這樣嗎? 我用Chome和IE開iGoogle都只是g-talk那個頁籤出現404 Not found, 可是用FireFox開iGoogle時,他發現404 Not f ...

google寄信給我,關於密碼重設

Una avatar
By Una
at 2009-10-26T22:56
我的信箱是是疊字 EX hellohelloatgmail.com 今天GOOGLE寄信給我,要我重設密碼,但是電子信箱卻是這個 hellohello.s9atgmail.com 我壓根沒申請過這個帳號,但是卻跑出這封信件 讓我大感不知所措,所以我重設了S9這一個信箱 沒想到我竟然可以進去,真是 ...

Google瀏覽器下載檔案問題

James avatar
By James
at 2009-10-26T17:04
※ 引述《culb (香草)》之銘言: : ※ 引述《jamhuang (Jam)》之銘言: : : 想請問一下 : : Google瀏覽器在抓檔案時 有辦法像ie一樣 : : 可選擇開啟或存檔嗎 : : 因為現在抓都是只有存檔 沒辦法直接執行的樣子 : : 還請解答了 謝謝 ~ : 點開下載檔案時, ...