ngmap
Version:
The Simplest AngularJS Google Maps V3 Directive
42 lines (40 loc) • 1.23 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('IconComplexCtrl', function($scope) {
var vm = this;
vm.image = {
url: 'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png',
size: [20, 32],
origin: [0,0],
anchor: [0, 32]
};
vm.shape = {
coords: [1, 1, 1, 20, 18, 20, 18 , 1],
type: 'poly'
};
vm.beaches = [
['Bondi Beach', -33.890542, 151.274856, 4],
['Coogee Beach', -33.923036, 151.259052, 5],
['Cronulla Beach', -34.028249, 151.157507, 3],
['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
['Maroubra Beach', -33.950198, 151.259302, 1]
];
});
</script>
</head>
<body ng-controller="IconComplexCtrl as vm">
<ng-map zoom="10" center="-33.9, 151.2">
<marker ng-repeat="beach in vm.beaches"
icon="{{vm.image}}"
shape="{{vm.shape}}"
title="{{beach[0]}}"
position="{{beach[1]}}, {{beach[2]}}"
z-index="{{beach[3]}}"></marker>
</ng-map>
</body>
</html>