Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. It can be viewed on:

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

gMarker.key undefined and it is REQUIRED!!

Below is the code: 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="[email protected]" 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?

like image 285
butYouDontLookLikeADeveloper Avatar asked Aug 14 '14 11:08

butYouDontLookLikeADeveloper


1 Answers

I believe you're missing the idkey parameter on your marker directive.

<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. You can read more about here.

like image 174
Andi Avatar answered Nov 14 '22 23:11

Andi