This article is an example of how PHP uses Google Maps. Share to everyone for your reference. Specifically as follows:
The PHP code is as follows:
Copy Code code as follows:
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 tutorial 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 are hard coded for demo
$location [0]= "200,8,51.369318,-2.133457";
List ($stat, $ACC, $north, $east) = Explode (",", $location [0]);
The HTML page is as follows:
Copy Code code as follows:
<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 Tutorial" ></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>
<body onload= "Load ()" onunload= "Gunload ()" >
<table><tr valign=top><td>
<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><form method=post> Change to
<select name=scale>
<option value=7 <?= Selected ($scale, 7)?> >Overview</option>
<option value=10 <?= selected ($scale, a)?> >County</option>
<option value=13 <?= selected ($scale)?> >Town</option>
<option value=16 <?= selected ($scale)?> >Street</option>
<option value=19 <?= selected ($scale)?> >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 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>
I hope this article will help you with your PHP program design.