我需要一些关于打字稿的帮助(我是打字稿中的完全noob)。我已经超过10天坚持这个问题,但无法解决。我想我完全失去了。你的帮助对我来说真的很宝贵。
我试图将谷歌地图api用于网络。 这是我的代码:
baisc.ts
///<reference path="../typings/globals/google.maps/google.maps.d.ts" />
var limit = 0;
var markers =[];
var labels="12345";
/*
var opts: {
center: new google.maps.LatLng(-36.850,174.763);
zoom: 14;
}; */
module Mapping {
export class GoogleMap {
public name: string;
public map: any;
public options: any;
constructor (mapDiv: Element){
this.name="GoogleMap";
this.options={center: new google.maps.LatLng(-36.850,174.763),zoom: 14};
this.map= new google.maps.Map(mapDiv, this.options);
google.maps.event.addListener(this.map,"click",()=> {
this.addMarker(event.currentTarget, this.map);
});
}
}
这是index.html
<!DOCTYPE html> <!--identifier of HTML5 -->
<html>
<head>
<meta charset = "utf-8">
<title>Here!</title>
<script src="https://apis.google.com/js/client.js?onload=listMarkers"></script>
<script defer
src="https://maps.googleapis.com/maps/api/js?key=MYAPIKEY"></script>
<script src="./js/second.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type "text/javascript">
function initialize(){
var mapCanvas = document.getElementById("map");
Mapping.GoogleMap(mapCanvas);
}
</script>
</head>
<body>
<div class="container" id ="page-container">
<h1 id="app-name">
Here!
<span src ="./image/placeholder (1).png"></span>
</h1>
<h2 id="page-header">
Mark simply and make assure your meeting spot with friends.
</h2>
<body onload="initialize()">
<div id="map">map</div>
<p>The markers' locations are: </p>
<pre id="output1"></pre>
<pre id="output2"></pre>
<pre id="output3"></pre>
<pre id="output4"></pre>
<pre id="output5"></pre>
</div>
<link rel="stylesheet" type="text/css" href="./node_modules/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="./css/style.css">
<script src="./node_modules/jquery/dist/jquery.min.js"></script>
<script src="./node_modules/bootstrap/dist/js/bootstrap.min.js"> </script>
</body>
</html>
当我运行此代码时,我得到了无法获取/错误。谁知道该怎么办?