allenhwkim/angularjs-google-maps
Demo
Documentation
Road Trip By StreetView
There is already one for this. However, I found myself doing totally different approach for this purpose than the existing one, such as;
- Everything in tag and attributes.
Thus, basic users don’t even have to know what Javascript is. - Expose all original Google Maps V3 api to the user.
No hiding, no wraping, 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’
To Get Started
For Bower users,
$ bower install ngmap
-
Include
ng-map.min.js
as well as google maps. -
name angular app as ngMap, or add it as a dependency
var myApp = angular.module('myApp', ['ngMap']);
After map is initialized, you will have one event and map instances
Event:
-
mapInitialized
with parameter with mapIn case your map directive scope is different from your controller scope, use this event to get the map instance.
app.controller(‘parentParentController’, function($scope) { $scope.$on(‘mapInitialized’, function(event, map) { map.setCenter( … ) … }); });
Instances:
$scope.map
$scope.map.markers
$scope.map.shapes
- etc
Lazy Loading
Simply wrap the map tag with map-lazy-load="http://maps.google.com/maps/api/js"
.
Release Notes
1.7.0
- added directions directive Example
- added places-auto-complete for input tag. Example
1.6.0
1.5.0
- added geo-callback attribute for map, marker, shape, and info-window. Example
1.4.0
- support lazy loading of maps js with directive, map-lazy-load, which does not require to
https://maps.google.com/maps/api/js
Example
1.3.0
- added drawing-manager directive. Thanks to Fangming Du Example
1.2.0
- events with
controller as
syntax, thanks to Simon
1.1.0
- marker directive can have icon attribute as JSON
- map with init-event attribute for initialization by an event
1.0.0 (covers all official google examples using directives).
-
marker
-
shapes
- circle
- polyline
- polygon
- rectangle
- image
-
layers
- traffic-layer
- transit-layer
- bicycling-layer
- dynamic-maps-engine-layer
- fusion-tables-layer
- heatmap-layer
- kml-layer
- maps-engine-layer
-
custom-control
-
info-window
-
map-data
-
map-type
-
overlay-map-type
Directives
As defined on MapOptions, you can add any attributes, and events starting witn on-
. Please note that event value must be a function.
Example:
i.e. < zoom=“11” center=”[40.74, -74.18]”
As defined on MarkerOptions, you can add any attributes, and events starting witn on-
.
Polyline, Circle, Polygon, Rectangle, and Images
Example:
Example:
Home1
Example:
Layer Directives
(deprecated) and (deprecated)