谷歌地图API v3-类型错误:表达式的结果'google.maps.LatLng'[defined]不
Google Maps API v3 - TypeError: Result of expression 'google.maps.LatLng' [undefined] is not a constructor
我正在创建一个静态html页面来显示数据中的多个位置。我刚刚复制了其中一个样本,正在反向工作,但我在Safari检查器中遇到了以下错误:
main.js:1SyntaxError: Parse error
sample.htm:10TypeError: Result of expression 'google.maps.LatLng' [undefined] is not a constructor.
这是我的html代码:
<!DOCTYPE html>
<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>Multi Markers Sample via Google Maps</title>
<link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
function initialize() {
var myLatlng = new google.maps.LatLng(-30.2965590,153.1152650);
var myLatlng1 = new google.maps.LatLng(-30.2956470,153.1123707);
var myLatlng2 = new google.maps.LatLng(-30.2864430,153.1360230);
var myOptions = {
zoom: 13,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
icon: 'http://www.google.com/intl/en_us/mapfiles/ms/icons/blue-dot.png',
title:"Original Location" });
var marker = new google.maps.Marker({
position: myLatlng1,
map: map,
title:"Tom Cruise" });
var marker = new google.maps.Marker({
position: myLatlng2,
map: map,
title:"Lady Gaga" });
}
</script>
</head>
<body onLoad="initialize()">
<div id="map_canvas"></div>
</body>
</html>
我不确定我在这里做错了什么——它实际上在Windows上的IE v8中有效,但在Safari中无效,我需要让它同时适用。
为您的谷歌地图请求添加回调函数。它将在谷歌加载所需的所有内容后执行。
http://maps.google.com/maps/api/js?sensor=false&callback=initialize
hi请使用JQuery使用此代码`
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Multi Markers Sample via Google Maps</title>
<script src="js/jquery-1.10.2.min.js"></script>
<link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<style>
#map_canvas {
height: 500px;
width: 100%;
}
</style>
<script type="text/javascript">
$(document).ready(function () {
var myLatlng = new google.maps.LatLng(-30.2965590, 153.1152650);
var myLatlng1 = new google.maps.LatLng(-30.2956470, 153.1123707);
var myLatlng2 = new google.maps.LatLng(-30.2864430, 153.1360230);
var myOptions = {
zoom: 13,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
icon: 'http://www.google.com/intl/en_us/mapfiles/ms/icons/blue-dot.png',
title: "Original Location"
});
var marker = new google.maps.Marker({
position: myLatlng1,
map: map,
title: "Tom Cruise"
});
var marker = new google.maps.Marker({
position: myLatlng2,
map: map,
title: "Lady Gaga"
});
});
</script>
</head>
<body >
<div id="map_canvas"></div>
</body>
</html>`
相关文章:
- 单击超链接时,如何使用Google Maps API v3缩放地图
- 应用“;矢量“;指向传单中的Point或LatLng
- 使用Google Maps API向标记添加多个字符
- Google Maps API OverlayView()在AngularJS指令中不起作用
- 使用Google Maps API驱动时间多边形
- 使用Google Maps JavaScript API v3和Geocoding API映射多个位置
- 将谷歌地图点击事件中的LatLng传递到rails控制器
- 将 jquery .position() 转换为 google maps latlng
- Google Maps APIv3 large polygon new google.maps.LatLng redun
- GWT Google Maps:setCenter:不是LatLng或LatLngLiteral:属性lat:不是数字
- 检查这是否是JavaScript中new google.maps.LatLng的实例
- 将值传递给google.maps.LatLng
- 如何使用变量来定义新的google.maps.LatLng()
- 不能使用google.maps.LatLng对象's late
- 谷歌地图地理编码器如何我可以返回值在新的Google .maps. latlng
- Google Maps JavaScript将变量放入LatLng()中
- 在Google Maps API V3中使用LatLng坐标数组绘制折线
- 将JSON字符串值分配给MVC 4中的google.maps.LatLng(lat,lon)中的Latitude和Lon
- 谷歌地图API v3-类型错误:表达式的结果'google.maps.LatLng'[defined]不
- TypeError: google.maps.latLng不是构造函数