Demo
Documentation
Road Trip By StreetView
Maps Can Talk |Custom Marker
If you like this, you also may like these:
There is already one for this. However, I found myself taking a totally different approach than the existing one, such as:
Everything in tag and attributes.
Thus, users don't even need knowledge of JavaScript.
Expose all original Google Maps V3 API to the user.
No hiding, no wrapping or whatsoever.By doing so, programmers don't need to learn how to use this module.You only need to know Google Maps V3 API.
There is a blog that introduces this module. The title of it is 'Google Map As The Simplest Way'
For Bower users,
$ bower install ngmap
Include ng-map.min.js
:<script src="/bower_components/ngmap/build/scripts/ng-map.min.js"></script>
Include Google Maps:<script src="http://maps.google.com/maps/api/js"></script>
Name your AngularJS app ngMap, or add it as a dependency
var myApp = angular.module('myApp', ['ngMap']);
To get the map instance use the NgMap.getMap()
function
app.controller('MyController', function(NgMap) {
NgMap.getMap().then(function(map) {
console.log(map.getCenter());
console.log('markers', map.markers);
console.log('shapes', map.shapes);
});
});
For npm users,
$ npm install ngmap
For Meteor users: https://atmospherejs.com/wormy/angularjs-google-maps
Simply wrap the map tag with map-lazy-load="https://maps.google.com/maps/api/js"
.
<div map-lazy-load="https://maps.google.com/maps/api/js">
<ng-map center="41,-87" zoom="3"></ng-map>
</div>
If you need to pass in an API key to the javascript, you can set a scopevariable in your controller (e.g. $scope.googleMapsUrl="https://maps.googleapis.com/maps/api/js?key=YOUR_KEY_HERE";
).This can be set from a constant value in your app to standardise the API key to pass to google for multiple controllers.
<div map-lazy-load="https://maps.google.com/maps/api/js"
map-lazy-load-params="{{googleMapsUrl}}">
<ng-map center="41,-87" zoom="3"></ng-map>
</div>
The usual reason why this happens is that the size of the map is changed after the map has been initialized. If you for some reason change the size of the div, you need to trigger the "resize" event and possible recenter the map.
var center = map.getCenter();
google.maps.event.trigger(map, "resize");
map.setCenter(center);
Ref.
Map
, Rectangle
, or Circle
`map.getBounds().contains(marker.getPosition());`
You can check this out: https://developers.google.com/maps/documentation/javascript/distancematrix.As you see, DistanceMatrix does not require map nor directive.
Another way to do this, is to use directions directive. As you see it here: https://rawgit.com/allenhwkim/angularjs-google-maps/master/testapp/directions2.html, you have access to DirectionsRenderer by using map.directionsRenderers[id]
https://developers.google.com/maps/documentation/javascript/reference?hl=en#DirectionsRenderer
You use getDirections()
or directions
, then calculate the distance from there. e.g.,
Distance:{{ map.directionsRenderers[0].directions.routes[0].legs[0].distance }}
本文翻译自:How to call a method defined in an AngularJS directive? I have a directive, here is the code : 我有一个指令,这里是代码: .directive('map', function() { return { restrict: 'E', replace: t
vue组件自定义标签 Vue 2 JS Google Map的自定义标记组件 (Custom marker component for vue 2 js google map) This component let user display custom html content on the map using Overlay. This component is an adaptation o
网上关于angularJS做上传文件基本上会用angular-fileinput这样一个BootStrap和angularJS整合做的一个上传文件优化,然而我们实际使用中,根本不会这样用,首先前端可能有使用其他样式会与bootstrap的样式冲突,其次需要引入fileinput的一系列js文件,挺不方便的。 那么,angularJS要怎么简单的做文件上传呢? 首先,先写一个js文件,直接把下面这段
问题内容: 有关此问题的改进解决方案,请参阅问题底部 我已经尝试了一段时间,以获取有关pagedown工作的指令。这是stackoverflow使用的完全相同的编辑器。Stackoverflow使此代码在此处可用: https://code.google.com/p/pagedown/ 互联网上有一些版本,但都无法正常运行。我需要的是一个将与所有编辑器按钮一起出现的控件,就像在内联编码以及作为ng
问题内容: 我正在尝试在AngularJS网络应用程序中实现 不可见的 reCAPTCHA。根据他们的文档,我应该在登录表单的提交按钮上添加一个名为“数据回调”的属性。但是,我使用ng- click将http请求的功能附加到按钮。那我应该在“数据回调”属性的值中输入什么呢?另外,如何知道recaptcha结果是否成功,并获取g- recaptcha-response与我的http请求一起发送到服务
我正在尝试在我的AngularJS web应用程序中实现不可见的reCAPTCHA。根据他们的文档,我应该在登录表单的提交按钮中添加一个名为“数据回调”的属性。但是,我使用ng click将http请求的函数附加到按钮。那么我应该在“数据回调”属性的值中输入什么呢?另外,我如何知道recaptcha结果是否成功,并获取g-recaptcha-response以使用http请求发送到服务器? htt
问题内容: 我正在考虑从lobbjs迁移到angularjs。 在骨干网中,我能够初始化一个视图,此时我将创建一个google map实例。然后,我可以平移/缩放/等并在视图之间切换,而不会丢失地图的当前状态。 鉴于以下使用angularjs: layout.html map.html 我能够创建一个指令来渲染地图。问题在于,每次我切换回地图视图时,都会重新加载地图。 因此,根据我对Angular
问题内容: 我正在使用http://angular-google-maps.org/,它是不错的Google角形地图库。但是我想使用这样的地图实例,它不是在angularjs上下文中加载的: 好的,我有mapInstance,我可以以编程方式使用它。但是在应用程序生命周期中,这种情况一直持续到很晚- 换句话说,我想在其他代码之前加载整个指令(并获取地图实例),而我只是不想使用其他地图事件。 问题答
问题内容: 我被要求为我们的一位客户构建一个小型Web应用程序,并认为这是一个尝试构建Web应用程序的不同框架的好机会。我们构建的大多数应用程序都是基于asp.net Web表单的,我们还没有在MVC架构中做任何事情,但是我渴望通过正确的工具以更结构化的方式构建Web应用程序。 我一直在研究asp.net MVC之类的东西,看起来不错,但是我想知道使用Google AngularJS框架之类的东西