ngmap
Version:
The Simplest AngularJS Google Maps V3 Directive
54 lines (51 loc) • 1.31 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('GroundoverlayRemoveCtrl', function(NgMap) {
var vm = this;
NgMap.getMap().then(function(map) {
vm.map = map;
});
vm.add = function() {
vm.map.shapes.foo.setMap(vm.map);
}
vm.remove = function() {
vm.map.shapes.foo.setMap(null);
};
});
</script>
</head>
<body>
<style>
div[ng-controller] {
position: relative;
}
#panel {
position: absolute;
top: 5px;
left: 50%;
margin-left: -90px;
z-index: 5;
background-color: #fff;
padding: 5px;
border: 1px solid #999;
}
</style>
<div ng-controller="GroundoverlayRemoveCtrl as vm">
<div id="panel">
<input ng-click="vm.remove()" type=button value="Remove overlay">
<input ng-click="vm.add()" type=button value="Restore overlay">
</div>
<ng-map zoom="13" center="40.740, -74.18">
<shape name="image" id="foo"
url="https://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg"
bounds="[[40.712216, -74.22655], [40.773941, -74.12544]]">
</shape>
</ng-map>
</div>
</body>
</html>