当前位置:首页 > PHP教程 > php高级应用 > 列表

php google地图应用实例代码

发布:smiling 来源: PHP粉丝网  添加日期:2014-09-09 16:19:34 浏览: 评论:0 
  1. function selected ( $param , $value ) {  
  2. if ( $param == $value ) print "SELECTED" ;  
  3. } 
  4.  
  5. # Collect any form data to control the display 
  6.  
  7. $scale = 10 ;  
  8. $maptype = "G_NORMAL_MAP" ;  
  9. if ( $_REQUEST [ scale ]) $scale = $_REQUEST [ scale ];  
  10. if ( $_REQUEST [ maptype ]) $maptype = $_REQUEST [ maptype ]; 
  11.  
  12. # Geocoding your location  
  13. # Note - you would cache this in a file  
  14. # The key is domain specific - your google maps教程 key 
  15.  
  16. /*  
  17. $location = file("http://maps.google.com/maps/geo?q=48+Spa+Road,+Melksham,+UK&  
  18. output=csv&key=ABQIAAAAvp3__HwvT3VkixIIbsW0axQuKI_6t1bH2P0vCI_Q8jfpn8qdNBQMnnelj  
  19. xh9czilkau_bYSCXteS_A");  
  20. */  
  21. # Following line is hard coded for demo  
  22. $location [ 0 ]= "200,8,51.369318,-2.133457" ;  
  23. list ( $stat , $acc , $north , $east ) = explode ( "," , $location [ 0 ]); 
  24.  
  25. ?> 
  26.  
  27. <html>  
  28. <head>  
  29. <title>Well House Manor, Melksham</title>  
  30. <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;  
  31. key=ABQIAAAAvp3__HwvT3VkixIIbsW0axQuKI_6t1bH2P0vCI_Q8jfpn8qdNBQMnneljxh9czilkau_  
  32. bYSCXteS_A"  
  33. type="text/javascript教程"></script>  
  34. <script type="text/javascript"> 
  35.  
  36. //<![CDATA[ 
  37.  
  38. function load() {  
  39. if (GBrowserIsCompatible()) {  
  40. var map = new GMap2(document.getElementById("map"));  
  41. map.setCenter(new GLatLng(51.36905, -2.1335), <?= $scale ?> );  
  42. map.setMapType( <?= $maptype ?> );  
  43. var manor = new GLatLng( <?= $north ?> , <?= $east ?> );  
  44. map.addOverlay(new GMarker(manor)); 
  45.  
  46. }  
  47. } 
  48.  
  49. //]]>  
  50. </script>  
  51. </head>  
  52. <body onLoad="load()" onUnload="GUnload()">  
  53. <table><tr valign=top><td>  
  54. <h1>Well House Manor, Melksham</h1>  
  55. <img src=http://filesimg.111cn.net/2010/03/20100525003348607.jpg><br>  
  56. &bull; Business Hotel in Melksham<br>  
  57. &bull; All rooms fitted to superior standard<br>  
  58. &bull; Internet Access throughout<br>  
  59. &bull; Plenty of parking and close to town centre<br><br>  
  60. <a href=http://www.wellhousemanor.co.uk>Well House  
  61. Manor website</a><hr>  
  62. <form method=POST> Change to  
  63. <select name=scale>  
  64. <option value=7 <?= selected ( $scale , 7 ) ?> >Overview</option>  
  65. <option value=10 <?= selected ( $scale , 10 ) ?> >County</option>  
  66. <option value=13 <?= selected ( $scale , 13 ) ?> >Town</option>  
  67. <option value=16 <?= selected ( $scale , 16 ) ?> >Street</option>  
  68. <option value=19 <?= selected ( $scale , 19 ) ?> >Building</option>  
  69. </select>  
  70. <select name=maptype>  
  71. <option value=G_NORMAL_MAP <?= selected ( $maptype , "G_NORMAL_MAP" ) ?> >  
  72. Normal map</option>  
  73. <option value=G_SATELLITE_MAP <?= selected ( $maptype , "G_SATELLITE_MAP" ) ?> >  
  74. Satellite data</option>  
  75. <option value=G_HYBRID_MAP <?= selected ( $maptype , "G_HYBRID_MAP" ) ?> > //开源代码phpfensi.com 
  76. Hybrid</option>  
  77. </select>  
  78. <input type=submit value="go!"></form><br>  
  79. This is a sample PHP page with Google Maps<br>  
  80. teach you how to write pages like this</a><br>  
  81. Date - <?= date ( "F, jS l Y" ) ?> <br> 
  82.  
  83. </td><td>  
  84. <div id="map" style="width: 450px; height: 550px"</div>  
  85. </td></tr></table>  
  86. </body>  
  87. </html>

Tags: php google地图 php应用实例

分享到: