作者sss5 (屁)
看板Ajax
标题[问题] goole map api 动态抓取地址
时间Wed Oct 28 22:14:34 2009
我是要从网页中资料库里的地址去读出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{
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
1F:→ sss5:这应该属於javascript范围吧..因为在php版问没人回= = 10/29 17:13
2F:→ terrybob:AJAX去作沟通 10/31 01:16