gpt4 book ai didi

javascript - 谷歌地图标记未在 chrome 和 safari 中显示..尝试了 Stackoverflow 上的所有答案

转载 作者:行者123 更新时间:2023-11-30 06:36:41 24 4
gpt4 key购买 nike

我在我的网页上使用谷歌标记。纬度、经度、名称和详细信息是使用 php 页面从数据库中获取的,然后使用 $.post 方法在 jquery 上使用它。

<?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 中不可见。错误是什么?我是否错误地使用了 json?

最佳答案

当你得到你的 json 数据时,你必须在回调中处理它们。在这里,您在 ajax 调用完成之前显示 map 和标记。将此呈现移动到 done 回调。

关于javascript - 谷歌地图标记未在 chrome 和 safari 中显示..尝试了 Stackoverflow 上的所有答案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13948549/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com