UNPKG

mohsen-angular-leaflet-directive

Version:

angular-leaflet-directive - An AngularJS directive to easily interact with Leaflet maps

45 lines 2.12 kB
app.controller('BasicTilesController', [ '$scope', function($scope) { var tilesDict = { openstreetmap: { url: "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", options: { attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' } }, opencyclemap: { url: "http://{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png", options: { attribution: 'All maps &copy; <a href="http://www.opencyclemap.org">OpenCycleMap</a>, map data &copy; <a href="http://www.openstreetmap.org">OpenStreetMap</a> (<a href="http://www.openstreetmap.org/copyright">ODbL</a>' } }, mapbox_outdoors: { name: 'Mapbox Outdoors', url: 'http://api.tiles.mapbox.com/v4/{mapid}/{z}/{x}/{y}.png?access_token={apikey}', type: 'xyz', options: { apikey: 'pk.eyJ1IjoiYnVmYW51dm9scyIsImEiOiJLSURpX0pnIn0.2_9NrLz1U9bpwMQBhVk97Q', mapid: 'bufanuvols.lia3no0m' } }, mapbox_wheat: { name: 'Mapbox Wheat Paste', url: 'http://api.tiles.mapbox.com/v4/{mapid}/{z}/{x}/{y}.png?access_token={apikey}', type: 'xyz', options: { apikey: 'pk.eyJ1IjoiYnVmYW51dm9scyIsImEiOiJLSURpX0pnIn0.2_9NrLz1U9bpwMQBhVk97Q', mapid: 'bufanuvols.lia35jfp' } } }; angular.extend($scope, { london: { lat: 51.505, lng: -0.09, zoom: 8 }, tiles: tilesDict.mapbox_wheat }); $scope.changeTiles = function(tiles) { $scope.tiles = tilesDict[tiles]; }; } ]);