ngmap
Version:
The Simplest AngularJS Google Maps V3 Directive
34 lines (32 loc) • 1.04 kB
HTML
<html ng-app="myApp">
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script src="script-tags-for-development.js"></script>
<script>
var app = angular.module('myApp', ['ngMap']);
app.controller('EventPropertiesController', function(NgMap) {
var vm = this;
NgMap.getMap().then(function(map) {
var infoWindow = map.infoWindows[1];
vm.zoomChanged = function(e) {
infoWindow.setContent('Zoom: ' + map.getZoom());
map.setCenter(infoWindow.getPosition());
}
});
});
</script>
</head>
<body ng-controller="EventPropertiesController as vm">
Assigning arguments in UI events
<br/>
When zoom level changed, the contents of infoWindow also updates.
<ng-map zoom="4" center="-25.363882, 131.044922"
default-style="true"
on-zoom_changed="vm.zoomChanged()">
<info-window id="1" position="-25.363882, 131.044922" visible="true">
<div ng-non-bindable>Change the zoom level</div>
</info-window>
</ng-map>
</body>
</html>