谷歌地图和jQuery错误消息-地理定位
Google maps and jQuery error messages - geolocation
我试图在我的网站上的一个简单的谷歌地图上显示用户位置,标题部分:
<head>
<!--jquery ,js scripts -->
<link rel="stylesheet" href="styles.css" />
<link rel="stylesheet"href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
<!--js scripts -->
<script src="jsCode.js"></script>
<script src ="sirJson.js"></script>
<!--gMap plugin API -->
<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&key=AIzaSyAVVQuKtaYbe30ZdNueAcpcXXXIik_5Rjs"></script>
<script src = "gmap.js"></script>
</head>
和地图div:
<div data-role="main" class="ui-content">
<div id="map"></div>
</div>
在js部分,我尝试过:
$('#mapButton').click (function () {
var myMap = document.getElementById('map');
var map = new google.maps.Map(myMap);
var mapOptions = {
center: new google.maps.LatLng(43.552965, 43.47315),
zoom: 10,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
}) ;
错误:
未捕获的类型错误:无法读取null 的属性"lat"
用户位置:
var myMap = document.getElementById('map');
var map = new google.maps.Map(myMap);
var mapOptions = {
center: new google.maps.LatLng(position.coords.latitude, position.coords.longitude),
zoom: 10,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
}) ;
错误
未捕获引用错误:位置未定义,您拒绝了检索位置的权限-错误。
小提琴http://jsfiddle.net/rma3jzgw/->修复一些东西->通过谷歌地图显示位置
我只是简单地从https://developers.google.com/maps/documentation/javascript/tutorial它起到了的作用
<script src="https://maps.googleapis.com/maps/api/js"></script>
<script>
function initialize() {
var map_canvas = document.getElementById('map_canvas');
var map_options = {
center: new google.maps.LatLng(16.470, 96.100),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(map_canvas, map_options)
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>-->
相关文章:
- CSS-如何定位内容数据标题
- Jquery菜单操作不稳定,定位不正确,存在一般错误
- 动态地改变“”的URL;添加新项目”;链接使用javascript/jquery
- document.open/document.write没有正确地清除chrome中的文档——这是chrome的错误吗
- 通过js在新选项卡中有条件地打开url
- 偶尔结结巴巴地说“;堆叠的”;translate()上的转换(v4.0.0-alpha40)
- 在Jquery detachment()和appendTo()之后定位元素
- 困在逻辑中试图定位动态的东西
- jQuery-有条件地附加HTML
- 如何轻松地将服务器端变量从Java代码转移到客户端代码
- 如何有效地将游戏数据存储在URL查询字符串中
- 如何使用Node.js最有效地解析网页
- 如何在悬停时流畅地更改单词
- "此网站似乎使用滚动链接定位效果.这可能不能很好地与异步平移一起工作;
- 使用JQuery动态地重新定位元素
- 如何将HTML元素准确地定位在您想要的位置
- 我如何不断地唠叨用户接受iPhone safari的地理定位?
- 响应式地将图像定位在背景图像上的特定目标上
- 动态地改变相对定位的内容到固定的内容- bug
- 为什么没有't createjs DOMElements像所有其他对象一样正确地定位在画布的左上角