- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我对 Angular 相当陌生,我正在尝试使用它来集成谷歌地图:https://github.com/allenhwkim/angularjs-google-maps
我遇到的问题是当我尝试使用 NgMap.getMap() 获取 map 实例时,当我 console.log NgMap.getMap 时,我收到“无法找到 map ”。这就是我的代码的样子:
partials/home.html:
<h1>practice locater</h1>
<ng-map id="map" center="[40.74, -74.18]"></ng-map>
Javascript:
var app = angular.module('RIThym',['ngResource','ngRoute','ngMap']);
app.config(['$routeProvider', function($routeProvider){
$routeProvider
.when('/', {
templateUrl: 'partials/home.html',
controller: 'HomeCtrl'
})
.otherwise({
redirectTo: '/'
});
}]);
app.controller('HomeCtrl',['$scope','$resource', 'NgMap',
function($scope, $resource, NgMap){
var Locations = $resource('/api/locations');
Locations.query(function(locations){
$scope.locations = locations;
});
var map = NgMap.getMap();
console.log(map);
NgMap.getMap().then(function(map){
console.log(map);
});
}]);
最佳答案
当 ng-map
指令具有 id
属性时,getMap
函数必须使用该 id
值作为它的第一个参数。
HTML
<h1>practice locater</h1>
<ng-map id="map" center="[40.74, -74.18]"></ng-map>
JS
//DO this
NgMap.getMap("map").then(function(map){
//NOT this
//NgMap.getMap().then(function(map){
console.log(map);
});
有关详细信息,请参阅 NgMap Provider API Reference
关于angularjs - NgMap错误 "could not find map",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37213835/
在我的一个客户项目中,我正在使用 ngMap ( http://ngmap.github.io/ ),但我对这个“指令”有问题:如何使用标记集群和这样的 map :
我在我的网络应用程序中使用ng-map。在 map View 中,我使用标记显示不同的位置。我想根据获取位置的对象内部的归档 isOpned 来更改每个标记的颜色。我尝试向标记添加 backgroun
我正在使用 angularjs 构建一个网络应用程序,它需要显示带有标记和方向的谷歌地图。就我目前所见,angluarJS 有两个主要的 google-map 扩展: https://github.c
我正在尝试使用 ng-map 在谷歌地图上显示信息窗口。这是我的代码: 我在每个标记上提供了一个带有纬度和经度值的点击函数。但在我的 Controller 中,我得到了未定义
我有一个场景,我必须在 map 上显示所有标记。我使用的是 Angular 图,我能够看到所有标记,但缩放级别无法控制。我无法限制显示三个 map 副本的缩放级别。我创建了一个 plunker . 我
我有一个表格和 map (ngMap),填写表格并在 map 上插入标记后,如果我单击提交,它将保存。但如果我再添加一个,标记将已经在先前坐标的位置。如果我手动重新加载页面,标记将离开 map 。如何
我正在使用 cordova 和 ionic 框架开发 android 应用程序。我想在我的应用程序中显示 map 。经过一些研究,我得到了 ionic 支持的结果 angular map .使用 bo
我一直在尝试实现类似于 this 中所做的事情网站。 到目前为止,我已经成功地使用 ngMaps 创建了一个带有圆圈的 map 。 .以下是我到目前为止所做的片段...... 任何人都可以帮助我如何继
我正在使用 ngmap 和 Angular js 在 map 中显示一组标记,没有问题。我需要画一条连接这些标记的线。 我的代码: 查看中: 在我的 Controller 中: var
Google map 允许人们从自动完成库中获取坐标。我似乎找不到使用 ngMap 来做到这一点的方法不涉及“controller as”语法。我想获取坐标并仅使用 $scope 将它们输出到控制台。
我能够做与 this 相同的事情例如,为了让用户绘制一个多边形,它工作得很好。现在我想在同一 map 内显示现有的多边形。我怎样才能做到这一点? 解释更多:我在我的 spring boot/angul
我在 Angular 应用程序中使用谷歌地图和 ngmap我在自定义标记方面遇到问题。 我的自定义标记内部有一个输入字段,用于为我的位置设置自定义名称。问题是在移动设备(Android 和 iOS)上
我在一个项目中使用 Allenhwkim 的精彩 ngMap。我知道我需要使用 Maps Javascript v3 API 来操作 map ,这很顺利,除了我无法获得任何事件监听器,例如 $goog
我正在使用 NgMap 在我的 Angular 应用程序的模态内生成 map 。模式是使用 Controller 中的 $modal 注入(inject)器生成的,并使用模板 View 构建 html
我正在使用 ngmaps ( https://github.com/allenhwkim/angularjs-google-maps ) 在我的应用程序中动态加载标记和信息窗口。 在我看来它看起来像这
我正在使用 ngmaps ( https://ngmap.github.io )、google maps api 和 angularJS 自定义 google map。我想要的是带上一个地方的标记,查
我在 angular 中使用 ngMap 进行谷歌地图集成。 下面是我的html代码 我的 Controller 代码是 //response get from server side
我在我的 Angular 应用程序中使用了 ng-map。在我的 map 中,我使用了方向,但我不需要 A 和 B 点。请帮我隐藏这些标记。 我有一个 solution 但这对 ng-map 没有帮助
我想使用 ngMap将 Google map 添加到我的应用中。 这些演示是“静态的”,因为它们只有硬编码的 HTML。我希望我的代码是“动态的”,因为它会定期要求服务器查看其数据库并返回一堆坐标来绘
我需要使用硬编码值在谷歌地图上绘制多边形。我使用了 ngMap(https://ngmap.github.io/)并使用了 ngMap 的绘图管理器,因为我还希望用户动态绘制多边形。如果我使用绘图管理
我是一名优秀的程序员,十分优秀!