<!DOCTYPE html >
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>PHP/MySQL & Google Maps Example</title>
<script type="text/javascript" src="
http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var marker;
var latlng;
var map;
var customIcons = {
restaurant: {
icon: '
http://labs.google.com/ridefinder/images/mm_20_blue.png',
shadow: '
http://labs.google.com/ridefinder/images/mm_20_shadow.png'
},
bar: {
icon: '
http://labs.google.com/ridefinder/images/mm_20_red.png',
shadow: '
http://labs.google.com/ridefinder/images/mm_20_shadow.png'
}
};
function load() {
map = new google.maps.Map(document.getElementById("map"), {
center: new google.maps.LatLng(24.688002, 46.722433),
zoom: 13,
mapTypeId: 'roadmap'
});
// Adding a new marker OR drag an existing one
google.maps.event.addListener(map, "click", function(event){
if (marker == null) {
addMarker(map,event.latLng);
}else{
marker.setMap(null);
addMarker(map,event.latLng);
}
});
var cities = eval([{"Region":{"city_id":"1","id":"1","name":"City1","lat":"24.730110212044263","lng":"46.65211200714111","zoom":"15"}},
{"Region":{"city_id":"1","id":"2","name":"City2","lat":"111111","lng":"5555555","zoom":"14"}}]);
function addMarker(map,latlng){
marker = new google.maps.Marker({
map: map,
position: latlng,
draggable: true
});
document.getElementById("latitude").value=marker.position.lat();
document.getElementById("longitude").value=marker.position.lng();
google.maps.event.addListener(marker, "dragstart", function() {
document.getElementById("latitude").value=marker.position.lat();
document.getElementById("longitude").value=marker.position.lng();
});
google.maps.event.addListener(marker, "dragend", function() {
document.getElementById("latitude").value=marker.position.lat();
document.getElementById("longitude").value=marker.position.lng();
});
}
}
function updateMap(){
var lat = 24.730110;
var lng = 46.652112;
var myLatLng=new google.maps.LatLng(lat, lng);
var zoom = 15;
map.setZoom(zoom);
map.setCenter(myLatLng);
}
</script>
</head>
<body onLoad="load()">
<p>
<span class="label">Select a City </span><br>
<select name="state" id="state" class="wide" onChange="updateMap()">
<option value="City1" >City1</option>
<option value="City2" >City2</option>
</select>
</p>
<table width="800x" height="600px" border="1" align="center" bordercolor="#CC3300">
<tr>
<td width="800" height="600" bordercolor="#CC3300"><div id="map" style="width: 800x; height: 600px" bordercolor="#CC3300"></div></td>
</tr>
</table>
<p> </p>
<form name="add" id="add" class="formular" method="post" type="hiden" action="view.php" enctype="multipart/form-data" >
<input type="hidden" readonly="true" name="longitude" id="longitude"/>
<input type="hidden" readonly="true" name="latitude" id="latitude"/>
<p align="center" class="marigintop"><input class="submit" type="submit" name="add_sub" id="add_sub" value="" /></p>
</form>
</body>
</html>