UNPKG

ngmap

Version:
55 lines (50 loc) 1.57 kB
<!doctype 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 = app || angular.module('myapp', ['ngMap']); app.controller('MyCtrl', function($compile, NgMap) { var vm = this; NgMap.getMap().then(function(map) { vm.map = map; }); vm.stores = { foo: { position:[41, -87], items: [1,2,3,4]}, bar:{ position:[41, -83], items: [5,6,7,8]} }; vm.showStore = function(evt, storeId) { vm.store = vm.stores[storeId]; vm.map.showInfoWindow('foo', this); }; vm.mouseover = function() { console.log('mouseover'); }; }); </script> </head> <body ng-controller="MyCtrl as vm"> <ng-map default-style="true" center="41,-87" zoom="3"> <info-window id="foo" on-mouseover="vm.mouseover()"> <div ng-non-bindable=""> Lat: {{anchor.getPosition().lat()}}<br/> Lng: {{anchor.getPosition().lng()}}<br/> <ul> <li ng-repeat='item in vm.store.items'>{{item}}</li> </ul> </div> </info-window> <marker ng-repeat="(id, store) in vm.stores" id="{{id}}" position="{{store.position}}" on-click="vm.showStore(event, id)"></marker> <info-window id="bar" on-mouseover="vm.mouseover()"> <div ng-non-bindable=""> Lat: {{anchor.getPosition().lat()}}<br/> Lng: {{anchor.getPosition().lng()}}<br/> </div> </info-window> <marker position="41, -79" on-click="vm.map.showInfoWindow('bar')" /> </ng-map> </body> </html>