php使用google地图应用实例
本文实例讲述了php使用google地图应用方法。分享给大家供大家参考。具体如下:
php代码如下:
functionselected($param,$value){ if($param==$value)print"SELECTED"; } #Collectanyformdatatocontrolthedisplay $scale=10; $maptype="G_NORMAL_MAP"; if($_REQUEST[scale])$scale=$_REQUEST[scale]; if($_REQUEST[maptype])$maptype=$_REQUEST[maptype]; #Geocodingyourlocation #Note-youwouldcachethisinafile #Thekeyisdomainspecific-yourgooglemaps教程key /* $location=file("http://maps.google.com/maps/geo?q=48+Spa+Road,+Melksham,+UK& output=csv&key=ABQIAAAAvp3__HwvT3VkixIIbsW0axQuKI_6t1bH2P0vCI_Q8jfpn8qdNBQMnnelj xh9czilkau_bYSCXteS_A"); */ #Followinglineishardcodedfordemo $location[0]="200,8,51.369318,-2.133457"; list($stat,$acc,$north,$east)=explode(",",$location[0]);
html页面如下:
<html> <head> <title>WellHouseManor,Melksham</title> <scriptsrc="http://maps.google.com/maps?file=api&v=2& key=ABQIAAAAvp3__HwvT3VkixIIbsW0axQuKI_6t1bH2P0vCI_Q8jfpn8qdNBQMnneljxh9czilkau_ bYSCXteS_A" type="text/javascript教程"></script> <scripttype="text/javascript"> //<![CDATA[ functionload(){ if(GBrowserIsCompatible()){ varmap=newGMap2(document.getElementById("map")); map.setCenter(newGLatLng(51.36905,-2.1335),<?=$scale?>); map.setMapType(<?=$maptype?>); varmanor=newGLatLng(<?=$north?>,<?=$east?>); map.addOverlay(newGMarker(manor)); } } //]]> </script> </head> <bodyonLoad="load()"onUnload="GUnload()"> <table><trvalign=top><td> <h1>WellHouseManor,Melksham</h1> <imgsrc=/get_pic/2010/03/20100525003348607.jpg><br> •BusinessHotelinMelksham<br> •Allroomsfittedtosuperiorstandard<br> •InternetAccessthroughout<br> •Plentyofparkingandclosetotowncentre<br><br> <ahref=http://www.wellhousemanor.co.uk>WellHouse Manorwebsite</a><hr> <formmethod=POST>Changeto <selectname=scale> <optionvalue=7<?=selected($scale,7)?>>Overview</option> <optionvalue=10<?=selected($scale,10)?>>County</option> <optionvalue=13<?=selected($scale,13)?>>Town</option> <optionvalue=16<?=selected($scale,16)?>>Street</option> <optionvalue=19<?=selected($scale,19)?>>Building</option> </select> <selectname=maptype> <optionvalue=G_NORMAL_MAP<?=selected($maptype,"G_NORMAL_MAP")?>> Normalmap</option> <optionvalue=G_SATELLITE_MAP<?=selected($maptype,"G_SATELLITE_MAP")?>> Satellitedata</option> <optionvalue=G_HYBRID_MAP<?=selected($maptype,"G_HYBRID_MAP")?>> Hybrid</option> </select> <inputtype=submitvalue="go!"></form><br> ThisisasamplePHPpagewithGoogleMaps<br> teachyouhowtowritepageslikethis</a><br> Date-<?=date("F,jSlY")?><br> </td><td> <divid="map"style="width:450px;height:550px"</div> </td></tr></table> </body> </html>
希望本文所述对大家的php程序设计有所帮助。