使用google MAP座標搜尋改善用戶體驗

来源:互联网 发布:直通车创意标题优化 编辑:程序博客网 时间:2024/06/06 11:39

效果如下:

 

核心方法:

function szb(i){i=$(i);if(!i){return false;}adr=i.get('value');if(adr==''){return false;}var geocoder=new google.maps.Geocoder();var LatLng=new google.maps.LatLng(23.7,121);geocoder.geocode({'address':adr},function(results,status){if(status==google.maps.GeocoderStatus.OK){LatLng=results[0].geometry.location;lat=(LatLng.lat()).round(7);lng=(LatLng.lng()).round(7);i.set('value',lat+','+lng);iMap3_Marker({'mess':'<b>'+adr+'</b>','lat':lat,'lng':lng,'zom':14,'spop':false,'box':'map','icon':'/img/beachflag.png'});tp(i,{'htm':adr+'的座標值是:<br>'+lat+'<br>'+lng});}else{i.set('value','');tp(i,{'htm':adr+'的座標值沒有找到,請嘗試更換關鍵字!'});}});}

 

0 0
原创粉丝点击