Windows 8应用程序开发中有关Google Map API的信息 [英] about google map api in windows 8 app developing
本文介绍了Windows 8应用程序开发中有关Google Map API的信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用VisualStudio2012在Windows-8中开发应用程序.当我将google提供的基本google map代码复制到javascript项目中的VS2012时.它不断告诉我一些错误.
代码在这里:
I want to develope apps in windows-8 using VisualStudio2012. When I copy the basic google map code which is given by google to VS2012 in javascript project. It keeps telling me there are some errors.
the code is here:
<!DOCTYPE html>
<html>
<head>
<title>Google Maps JavaScript API v3 Example: Map Simple</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
html, body, #map_canvas {
margin: 0;
padding: 0;
height: 100%;
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script>
var map;
function initialize() {
var mapOptions = {
zoom: 8,
center: new google.maps.LatLng(-34.397, 150.644),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map_canvas'),
mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map_canvas"></div>
</body>
</html>
错误在此行中:
google.maps.event.addDomListener(窗口,加载",初始化);
错误是:
JavaScript运行时错误:"google"未定义
所以请帮帮我!
the error is in this line:
google.maps.event.addDomListener(window, ''load'', initialize);
the error is:
JavaScript runtime error: "google"undefined
so plz help me!
推荐答案
替换
replace
google.maps.event.addDomListener(window, 'load', initialize);
下面的代码行..
with following line of code..
window.onload=initialize;
仍然有同样的错误.
JavaScript运行时错误:"google"未定义
如果有人给出了应该很棒的解决方案.
still we have getting same error.
JavaScript runtime error: "google"undefined
if any one give solution that''s should be great.
尝试这个
try this
var map;
function initialize() {map = new google.maps.Map(document.getElementById('map'), {
zoom: intZoomLevel,
center: new google.maps.LatLng(-34.397, 150.644),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
这篇关于Windows 8应用程序开发中有关Google Map API的信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文