UNPKG

mohsen-angular-leaflet-directive

Version:

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

74 lines (71 loc) 3.02 kB
<!DOCTYPE html> <html ng-app="demoapp"> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script src="../bower_components/angular/angular.min.js"></script> <script src="../bower_components/leaflet/dist/leaflet.js"></script> <script src="../dist/angular-leaflet-directive.min.js"></script> <link rel="stylesheet" href="../bower_components/leaflet/dist/leaflet.css" /> <script> var app = angular.module("demoapp", ["leaflet-directive"]); app.controller('BasicTilesWMSController', [ '$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' } }, standard: { name: 'MAP Standard', type: 'wms', url: 'https://api.minu.mn/wms', layerParams: { layers: 'mongolid:mimap', format: 'image/png', transparent: true, tiled: true, version: '1.3.0', maxZoom: 19 } }, blue: { name: 'MAP Blue', type: 'wms', url: 'https://api.minu.mn/wms', layerParams: { layers: 'mongolid:mimap_blue', // it's published not yet. format: 'image/png', transparent: true, tiled: true, version: '1.3.0', maxZoom: 19 } } }; angular.extend($scope, { ulaanbaatar: { lat: 47.918464, lng: 106.917678, zoom: 5 }, tiles: tilesDict.openstreetmap }); $scope.changeTiles = function(tiles) { $scope.tiles = tilesDict[tiles]; }; } ]); </script> </head> <body ng-controller="BasicTilesWMSController"> <leaflet lf-center="ulaanbaatar" lf-tiles="tiles" lf-defaults="defaults" width="100%" height="480px"></leaflet> <h1>Loading WMS tiles example</h1> <p>Change tiles clicking in the buttons below:</p> <p> <button ng-click="changeTiles('openstreetmap')" class="btn btn-default">OpenStreetMap Tiles</button> <button ng-click="changeTiles('standard')" class="btn btn-default">Standard WMS Tiles</button> <button ng-click="changeTiles('blue')" class="btn btn-default">Blue WMS Tiles</button> </p> <p>Current TileLayer Url: <strong ng-bind="tiles.url"></strong></p> </body> </html>