ngMaps: InvalidValueError: setPlace: not an Object
ngMaps: InvalidValueError: setPlace: not an Object
我正在使用 ngmaps (https://ngmap.github.io), google maps api and angularJS. What I want is to bring the marker of a place, look in the documentation of the api of google maps (https://developers.google.com/maps/documentation/javascript/reference?hl=en) 自定义 google 地图,并且有一个选项调用 "place"我的理解是放ID的地方。
当我加载网页时,它在控制台 "InvalidValueError: setPlace: not an Object" 中给我这个错误。我找不到那样的东西。
我的代码是:
var app = angular.module("app", ["ngMap"]);
<ng-map zoom="16" center="[-33.140981,-68.48775]">
<marker
place="ChIJycfzCxhdfpYRL"
title="Cherry"
position="[-33.140981,-68.48775]"
z-index="1">
</marker>
</ng-map>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<script src="http://rawgit.com/allenhwkim/angularjs-google-maps/master/build/scripts/ng-map.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDR3Q2Db6TbqNpXecvdHERFxK3RBRII9f8"></script>
如果有人能帮助我,我非常感谢!
对不起我的英语!
此致!
根据 MarkerPlace object specification place
属性接受以下格式:
{"placeId": "<placeid>","location": {"lat": <lat>, "lng":<lng>}, "query": "<query>"}
在您的情况下,place
值可以这样指定:
<marker place="{'placeId': 'ChIJycfzCxhdfpYRL','location': {'lat': -33.140981, 'lng':-68.48775}}" title="Cherry" z-index="1"></marker>
例子
angular.module('map-app', ['ngMap'])
.controller('map-controller', ['NgMap',
function (NgMap) {
}]);
<script src="https://code.angularjs.org/1.4.8/angular.js"></script>
<script src="https://maps.googleapis.com/maps/api/js"></script>
<script src="https://rawgit.com/allenhwkim/angularjs-google-maps/master/build/scripts/ng-map.js"></script>
<div ng-app="map-app" ng-controller="map-controller">
<ng-map center="-33.140981,-68.48775" zoom="4">
<marker place="{'placeId': 'ChIJycfzCxhdfpYRL','location': {'lat': -33.140981, 'lng':-68.48775}}" title="Cherry" z-index="1"></marker>
</ng-map>
</div>
我正在使用 ngmaps (https://ngmap.github.io), google maps api and angularJS. What I want is to bring the marker of a place, look in the documentation of the api of google maps (https://developers.google.com/maps/documentation/javascript/reference?hl=en) 自定义 google 地图,并且有一个选项调用 "place"我的理解是放ID的地方。 当我加载网页时,它在控制台 "InvalidValueError: setPlace: not an Object" 中给我这个错误。我找不到那样的东西。 我的代码是:
var app = angular.module("app", ["ngMap"]);
<ng-map zoom="16" center="[-33.140981,-68.48775]">
<marker
place="ChIJycfzCxhdfpYRL"
title="Cherry"
position="[-33.140981,-68.48775]"
z-index="1">
</marker>
</ng-map>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<script src="http://rawgit.com/allenhwkim/angularjs-google-maps/master/build/scripts/ng-map.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDR3Q2Db6TbqNpXecvdHERFxK3RBRII9f8"></script>
如果有人能帮助我,我非常感谢!
对不起我的英语!
此致!
根据 MarkerPlace object specification place
属性接受以下格式:
{"placeId": "<placeid>","location": {"lat": <lat>, "lng":<lng>}, "query": "<query>"}
在您的情况下,place
值可以这样指定:
<marker place="{'placeId': 'ChIJycfzCxhdfpYRL','location': {'lat': -33.140981, 'lng':-68.48775}}" title="Cherry" z-index="1"></marker>
例子
angular.module('map-app', ['ngMap'])
.controller('map-controller', ['NgMap',
function (NgMap) {
}]);
<script src="https://code.angularjs.org/1.4.8/angular.js"></script>
<script src="https://maps.googleapis.com/maps/api/js"></script>
<script src="https://rawgit.com/allenhwkim/angularjs-google-maps/master/build/scripts/ng-map.js"></script>
<div ng-app="map-app" ng-controller="map-controller">
<ng-map center="-33.140981,-68.48775" zoom="4">
<marker place="{'placeId': 'ChIJycfzCxhdfpYRL','location': {'lat': -33.140981, 'lng':-68.48775}}" title="Cherry" z-index="1"></marker>
</ng-map>
</div>