2
我在我的網頁上使用谷歌標記。緯度,經度,名稱和細節從數據庫中使用PHP頁面,然後M使用它在jQuery使用$ .post方法。谷歌地圖標記不顯示在鉻和safari..Try所有答案Stackoverflow
<?php
//Basic environment setup (error handling and logging, cookies/sessions, php directives etc)
require_once $_SERVER['DOCUMENT_ROOT'] . '/../Config/path_config.php';
require_once C_PATH_UTILITY_MANAGER_PAGESETUP;
Page_Setup_Manager::setDefaultPageSettings();
require_once C_DIR_UTILITY_EVENTS_DATAACCESS;
$eventsdats=Eventsdata::getevents();
$temp=array();
foreach($eventsdats as $singlemapevent)
{
array_push($temp,array($singlemapevent['ename'],
(floatval($singlemapevent['latitude'])),
(floatval($singlemapevent['longitude'])),
($singlemapevent['edate']),
($singlemapevent['etime']),
($singlemapevent['edetail'])
));
}
echo json_encode($temp);
//Result[["Second Event",19.0554748,72.8497017,"17-12-2012","17:57 ","This is the
social detail;"],["Demo Event",19.2097381,72.8737017,"08-12- 2012","09:34 ","This event
was held in bhayander by ganesh mandhre"],]
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false">
</script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
function initialize() {
markers=[];
temp=[];
final_markers=[];
$.post('maps_data.php',{},function(data){
},"json").done(function(data){
markers=(data);
$.each(data,function(index,value){
final_markers.push($.makeArray(value));
});
markers=final_markers;
});
alert(markers);
var latlng = new google.maps.LatLng(19.0554748, 72.8497017);
var settings = {
zoom: 10,
center: latlng,
visible:true,
mapTypeControl: true,
mapTypeControlOptions: {style:
google.maps.MapTypeControlStyle.DROPDOWN_MENU},
navigationControl: true,
navigationControlOptions: {style:
google.maps.NavigationControlStyle.SMALL},
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new
google.maps.Map(document.getElementById("map_canvas"), settings);
var infowindow = new google.maps.InfoWindow(), marker, i;
for (i = 0; i < markers.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(markers[i][1], markers[i][2]),
map: map
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
var contentString = '<div id="content">'+
'<div id="siteNotice">'+
'</div>'+
'<h1 id="firstHeading" class="firstHeading">'+markers[i][0]+'</h1>'+
'<div id="bodyContent">'+
'<p>'+markers[i][3]+'</p>'+
'<p>'+markers[i][4]+'</p>'+
'<p>'+markers[i][5]+'</p>'+
'</div>'+
'</div>';
infowindow.setContent(contentString);
infowindow.open(map, marker);
}
})(marker, i));
}
}
</script>
<title>Untitled Document</title>
</head>
<body onload="initialize()">
<div id="map_canvas" style="width:100%; height:350px"></div>
</body>
</html>
的標記是在Firefox可見,但無法在Chrome和safari..What是錯誤?我不正確地使用json嗎?
控制檯中是否有錯誤? –
「什麼是錯誤?」 - 你告訴我們 –
控制檯沒有錯誤 – Ashish