欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

php使用google地图应用实例

程序员文章站 2023-04-03 09:54:56
本文实例讲述了php使用google地图应用方法。分享给大家供大家参考。具体如下: php代码如下: 复制代码 代码如下:function selected ( $pa...

本文实例讲述了php使用google地图应用方法。分享给大家供大家参考。具体如下:

php代码如下:

复制代码 代码如下:
function selected ( $param , $value ) { 
if ( $param == $value ) print "selected" ; 
}
 
# collect any form data to control the display
 
$scale = 10 ; 
$maptype = "g_normal_map" ; 
if ( $_request [ scale ]) $scale = $_request [ scale ]; 
if ( $_request [ maptype ]) $maptype = $_request [ maptype ];
 
# geocoding your location 
# note - you would cache this in a file 
# the key is domain specific - your google maps教程 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"); 
*/ 
# following line is hard coded for demo 
$location [ 0 ]= "200,8,51.369318,-2.133457" ; 
list ( $stat , $acc , $north , $east ) = explode ( "," , $location [ 0 ]);

html页面如下:

复制代码 代码如下:
<html> 
<head> 
<title>well house manor, melksham</title> 
<script src="http://maps.google.com/maps?file=api&v=2& 
key=abqiaaaavp3__hwvt3vkixiibsw0axquki_6t1bh2p0vci_q8jfpn8qdnbqmnneljxh9czilkau_ 
byscxtes_a" 
type="text/javascript教程"></script> 
<script type="text/javascript">
 
//<![cdata[
 
function load() { 
if (gbrowseriscompatible()) { 
var map = new gmap2(document.getelementbyid("map")); 
map.setcenter(new glatlng(51.36905, -2.1335), <?= $scale ?> ); 
map.setmaptype( <?= $maptype ?> ); 
var manor = new glatlng( <?= $north ?> , <?= $east ?> ); 
map.addoverlay(new gmarker(manor));
 

}
 
//]]> 
</script> 
</head> 
<body onload="load()" onunload="gunload()"> 
<table><tr valign=top><td> 
<h1>well house manor, melksham</h1> 
<img src=/get_pic/2010/03/20100525003348607.jpg><br> 
• business hotel in melksham<br> 
• all rooms fitted to superior standard<br> 
• internet access throughout<br> 
• plenty of parking and close to town centre<br><br> 
<a href=http://www.wellhousemanor.co.uk>well house 
manor website</a><hr> 
<form method=post> change to 
<select name=scale> 
<option value=7 <?= selected ( $scale , 7 ) ?> >overview</option> 
<option value=10 <?= selected ( $scale , 10 ) ?> >county</option> 
<option value=13 <?= selected ( $scale , 13 ) ?> >town</option> 
<option value=16 <?= selected ( $scale , 16 ) ?> >street</option> 
<option value=19 <?= selected ( $scale , 19 ) ?> >building</option> 
</select> 
<select name=maptype> 
<option value=g_normal_map <?= selected ( $maptype , "g_normal_map" ) ?> > 
normal map</option> 
<option value=g_satellite_map <?= selected ( $maptype , "g_satellite_map" ) ?> > 
satellite data</option> 
<option value=g_hybrid_map <?= selected ( $maptype , "g_hybrid_map" ) ?> >
hybrid</option> 
</select> 
<input type=submit value="go!"></form><br> 
this is a sample php page with google maps<br> 
teach you how to write pages like this</a><br> 
date - <?= date ( "f, js l y" ) ?> <br>
 
</td><td> 
<div id="map" style="width: 450px; height: 550px"</div> 
</td></tr></table> 
</body> 
</html>

希望本文所述对大家的php程序设计有所帮助。