简体   繁体   English

gMarker.key未定义,它是必需的!! 角度和谷歌地图应用程序中的错误

[英]gMarker.key undefined and it is REQUIRED!! error in angular and google maps app

I have an application where I am trying to implement google maps on angular app to show where the coordinates are on the map when the user selects a place. 我有一个应用程序,我试图在角应用程序上实现谷歌地图,以显示当用户选择一个地方时坐标在地图上的位置。 When I try to load this app i get the error. 当我尝试加载此应用程序时,我收到错误。 The HTML works fine but google map does not show on my app. HTML工作正常,但谷歌地图不会显示在我的应用程序上。 It can be viewed on: 可以查看:

http://creative.coventry.ac.uk/~4078078/Map/

gMarker.key undefined and it is REQUIRED!! gMarker.key未定义,它是必需的!!

Below is the code: HTML: 以下是代码:HTML:

 <script src="http://maps.googleapis.com/maps/api/js?libraries=weather,geometry,visualization&sensor=false&language=en&v=3.14"></script>
<script data-require="angular.js@1.2.x" src="http://code.angularjs.org/1.2.16/angular.js" data-semver="1.2.16"></script>

<script src="http://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.underscore.min.js"></script>
<script src="http://rawgithub.com/angular-ui/angular-google-maps/master/dist/angular-google-maps.js"></script>
<script src="controllers.js"></script>
</head>

<body ng-controller="mainCtrl">
<select ng-model="selectedCoordinate" ng-options="coordinate.caption for coordinate in coordinates">

</select>

<label>zoom</label>
<input type="number" ng-model="zoom"/>

<div id="map_canvas">
<google-map center="selectedCoordinate" zoom="zoom" draggable="true" options="options">
  <marker coords="selectedCoordinate"></marker>
</google-map>
</div>

I have provided head files as there have been errors due to the files before. 由于之前的文件存在错误,我提供了头文件。 How can I resolve this error? 我该如何解决这个错误?

I believe you're missing the idkey parameter on your marker directive. 我相信你错过了你的marker指令的idkey参数。

<div id="map_canvas">
  <google-map center="selectedCoordinate" zoom="zoom" draggable="true" options="options">
    <marker idkey="{expression}" coords="selectedCoordinate"></marker>
  </gooogle-map>
</div>

This is new in version 1.2.0. 这是1.2.0版中的新增功能。 You can read more about here . 你可以在这里阅读更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM