我的 post() 结果只显示其他 map.php 生成的数据,但无法显示地图框。我正在通过 post() 发送 id,它显示了来自 mysql 数据库的确切 php 数据。只有地图 div 是空的。以下是代码。
$(document).ready(function() {
$(".mylink").click(function(){
var $linkattr = $(this).attr("rel");
// alert($linkattr);
$.post("map.php", {myid:$linkattr}).done(function(data) {
$("#mapcomeshere").html(data);
evt.preventDefault();
});
});
});
我的 map.php 脚本是
<?php
include('db.php');
$myid = "25";//$_POST['myid'];
$result = mysql_query("select * from property Where Id = '" . $myid ."' AND status = 1");
$row = mysql_fetch_array($result);
echo $row['Id'] . " : " . $row['owner'] . " : " . $row['lnglat'] . $row['propertyadd'] ."<br>";
$maploc = $row['lnglat'];
$myadd = $row['propertyadd'];
?>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
google.maps.event.addDomListener(window, 'load', function() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 13,
center: new google.maps.LatLng(24.893379,67.028061),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var infoWindow = new google.maps.InfoWindow;
var onMarkerClick = function() {
var marker = this;
var latLng = marker.getPosition();
infoWindow.setContent('<?php echo $myadd ?>');
infoWindow.open(map, marker);
};
google.maps.event.addListener(map, 'click', function() {
infoWindow.close();
});
var marker1 = new google.maps.Marker({
map: map,
position: new google.maps.LatLng(<?php echo $maploc ?>)
});
google.maps.event.addListener(marker1, 'click', onMarkerClick);
});
</script>
hi
<div id="map"></div>
请帮忙