效果如下:

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

 

核心方法:

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+'的座標值沒有找到,請嘗試更換關鍵字!'});
		}
	});
}

 

相关文章:

  • 2021-10-11
  • 2021-09-22
  • 2022-02-27
  • 2021-12-22
  • 2022-12-23
  • 2021-11-23
  • 2021-09-07
  • 2021-05-17
猜你喜欢
  • 2022-12-23
  • 2021-12-22
  • 2021-10-30
  • 2022-12-23
  • 2021-11-11
  • 2021-08-02
  • 2022-01-12
相关资源
相似解决方案