Google maps api 3 试图让谷歌地图开始工作
我正在玩谷歌地图V3 API和StyledMarkers。数据来自返回几百个点的PHP/MySQL查询 下面的代码返回了我需要的所有内容,除了将其放大到适当的级别(在本例中,我知道是10)之外,它工作正常Google maps api 3 试图让谷歌地图开始工作,google-maps-api-3,Google Maps Api 3,我正在玩谷歌地图V3 API和StyledMarkers。数据来自返回几百个点的PHP/MySQL查询 下面的代码返回了我需要的所有内容,除了将其放大到适当的级别(在本例中,我知道是10)之外,它工作正常 地图-无刷新 函数初始化(){ var mylatng=newgoogle.maps.LatLng(,); var bounds=new google.maps.LatLngBounds(); 变量myOptions={ 缩放:9, 中心:myLatLng, mapTypeId:google
地图-无刷新
函数初始化(){
var mylatng=newgoogle.maps.LatLng(,);
var bounds=new google.maps.LatLngBounds();
变量myOptions={
缩放:9,
中心:myLatLng,
mapTypeId:google.maps.mapTypeId.ROADMAP
};
var map=new google.maps.map(document.getElementById(“show_map”),myOptions);
var varLatLng=新的google.maps.LatLng(,);
扩展(varLatLng);
var styleMaker=new StyledMarker({styleIcon:new StyledIcon(StyledIconTypes.BUBBLE,{color:,text:}),position:new google.maps.LatLng('',''),flat:true,zIndex:,map:map});
映射边界(bounds);
}
有人知道我做错了什么吗?编程部门的能力不是很强。JavaScript区分大小写 使用
map.fitBounds(bounds)
代替map.fitBounds(bounds)
您应该在Javascript控制台中看到一个关于
fitbounds
不是有效方法或类似方法的错误。Duh!我找了这么久,没找到。干杯
<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 echo returnval("event_name","events",$_GET['eid']); ?> Map - No Refresh</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="StyledMarker.js"></script>
<script type="text/javascript">
function initialize() {
var myLatLng = new google.maps.LatLng(<?php echo $evlat; ?>, <?php echo $evlng; ?>);
var bounds = new google.maps.LatLngBounds();
var myOptions = {
zoom: 9,
center: myLatLng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("show_map"), myOptions);
<?php
$iconcntr = 0;
while ($row = mysql_fetch_array($result)) {
$iconcntr ++;
$rfa_no = $row['rfa_no'];
$longitude = $row['longitude'];
$latitude = $row['latitude'];
if ($row['rfa_priority'] == 1) {
$iconclr = "FF0000";
} elseif ($row['rfa_priority'] == 2) {
$iconclr = "FFFF00";
} else {
$iconclr = "FFFFFF";
}
?>
var varLatLng = new google.maps.LatLng(<?php echo $latitude; ?>,<?php echo $longitude; ?>);
bounds.extend(varLatLng);
var styleMaker<?php echo $iconcntr; ?> = new StyledMarker({styleIcon:new StyledIcon(StyledIconTypes.BUBBLE,{color:"<?php echo $iconclr; ?>",text:"<?php echo $rfa_no; ?>"}),position:new google.maps.LatLng('<?php echo $latitude; ?>', '<?php echo $longitude; ?>'),flat:true,zIndex:<?php echo ($iconcntr+1000); ?>,map:map});
<?php
}
?>
map.fitbounds(bounds);
}
</script>
</head />
<body style="margin:0px; padding:0px;" onload="initialize()" />
<div id="show_map" style="width:100%; height:100%;"></div>
</body>
</html>