[請益] goole map api 動態抓取地址
我是要從網頁中資料庫裡的地址去讀出google map位址
如果是在同一個網頁上執行,就沒問題
如果新開啟網頁來顯示地圖,會有開啟後,沒執行js的函數
--------------(這是準備開啟電子地圖的網頁)
<input type="hidden" name="Addr" value="<?php echo $row_house_qry_2['Addr']; ?>"/>
(用hidden來讀取Addr的資料)
<input name="button" type="button" value="Search" onclick="javascript:
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.51715755462646);
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>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.40.66.61
※ 編輯: sss5 來自: 114.40.66.61 (10/26 09:44)
→
10/26 11:12, , 1F
10/26 11:12, 1F
→
10/26 15:06, , 2F
10/26 15:06, 2F
※ 編輯: sss5 來自: 114.40.66.61 (10/26 15:06)
→
10/26 15:26, , 3F
10/26 15:26, 3F
PHP 近期熱門文章
PTT數位生活區 即時熱門文章