Created
October 31, 2014 19:47
-
-
Save MioGreen/242c0f46a3ede0b28763 to your computer and use it in GitHub Desktop.
ngLeaflet sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (window, angular, undefined) { | |
'use strict'; | |
angular.module('shell') | |
.controller('MapController', ['$scope', | |
function ($scope) { | |
$scope.layers = { | |
baselayers: { | |
yandex: { | |
name: 'Yandex', | |
type: 'yandex', | |
layerOptions: { | |
layerType: 'map' | |
} | |
}, | |
google: { | |
name: 'Google', | |
layerType: 'ROADMAP', | |
type: 'google' | |
}, | |
osm: { | |
name: 'OpenStreetMap', | |
type: 'xyz', | |
url: 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', | |
layerOptions: { | |
subdomains: ['a', 'b', 'c'], | |
attribution: '© OpenStreetMap contributors' | |
} | |
}, | |
} | |
}; | |
$scope.center = {}; | |
$scope.markers = {}; | |
$scope.$watch('coordinates', function(coordinates) { | |
if (!coordinates) { | |
return; | |
} | |
$scope.center = { | |
lat: $scope.coordinates.latitude, | |
lng: $scope.coordinates.longitude, | |
zoom: 16 | |
}; | |
$scope.markers = { | |
coordinates: { | |
lat: $scope.coordinates.latitude, | |
lng: $scope.coordinates.longitude | |
} | |
}; | |
}); | |
} | |
]); | |
})(window, window.angular); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="map" class="one-whole push--bottom" map coordinates="ad.geoCoordinates" style="width: 100%; height:300px"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.leaflet-top, .leaflet-bottom { | |
z-index: 4; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<leaflet layers="layers" center="center" markers="markers" height="100%" width="100%"></leaflet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (window, angular, undefined) { | |
'use strict'; | |
angular.module('shell') | |
.directive('map', [function() { | |
return { | |
restrict: 'EA', | |
scope:{ | |
coordinates: '=coordinates' | |
}, | |
templateUrl:'common/shell/ui/map/view.html', | |
controller: 'MapController' | |
}; | |
}]); | |
})(window, window.angular); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment