我已经关注了从 mysql db 获取单个纬度和经度的 php 页面,它可以通过鼠标进行编辑。我的意思是我可以通过单击标记来移动位置。
好吧,现在,我的数据库中很少有经纬度。我想在地图上显示所有经纬度。我怎样才能做到这一点。
Javascript代码:
<script type="text/javascript" src="http://maps.googleapis.com/maps/api
/js?sensor=false"></script>
<script type="text/javascript">
// Map Initialize function
function initialize()
{
// Set static latitude, longitude value
var latlng = new google.mpaps.LatLng(<?php echo $lat_d; ?>, <?php echo $long_d; ?>);
// Set map options
var myOptions = {
zoom: 16,
center: latlng,
panControl: true,
zoomControl: true,
scaleControl: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
// Create map object with options
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
// Create and set the marker
marker = new google.maps.Marker({
map: map,
draggable:true,
position: latlng
});
// Register Custom "dragend" Event
google.maps.event.addListener(marker, 'dragend', function() {
// Get the Current position, where the pointer was dropped
var point = marker.getPosition();
// Center the map at given point
map.panTo(point);
// Update the textbox
document.getElementById('txt_latlng').value=point.lat()+", "+point.lng();
});
}
</script>
html代码:
<div style="float:left; position:relative; width:550px; border:0px #000 solid;">
<div id="map_canvas" style="width:550px;height:400px;border:solid black 1px;"></div>
</div>
php代码:
$id = (int) $_GET['id'];
$sql = mysql_query("SELECT * FROM parkings WHERE LocId = '$id'");
$res = mysql_fetch_array($sql);
$lat_d = $res['latitude'];
$long_d = $res['longitude'];
任何想法或我该怎么做?