|
| 1 | +<!DOCTYPE html> |
| 2 | +<html ng-app="demoapp"> |
| 3 | +<head> |
| 4 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 5 | + <script src="../bower_components/angular/angular.min.js"></script> |
| 6 | + <script src="../bower_components/leaflet/dist/leaflet.js"></script> |
| 7 | + <script src="../dist/angular-leaflet-directive.min.js"></script> |
| 8 | + <link rel="stylesheet" href="../bower_components/leaflet/dist/leaflet.css" /> |
| 9 | + <script> |
| 10 | + var app = angular.module("demoapp", ["leaflet-directive"]); |
| 11 | + app.controller('MarkersCompiledWithoutIconController', [ '$scope', function($scope) { |
| 12 | + $scope.setSourceMarker = function () { |
| 13 | + alert($scope.markers.popup.lat + " " + $scope.markers.popup.lng) |
| 14 | + } |
| 15 | + |
| 16 | + $scope.setDestinationMarker = function () { |
| 17 | + alert($scope.markers.popup.lat + " " + $scope.markers.popup.lng) |
| 18 | + }; |
| 19 | + |
| 20 | + var getNewPopupMarker = function(lat, lng) { |
| 21 | + return { |
| 22 | + lat: lat, |
| 23 | + lng: lng, |
| 24 | + focus: true, |
| 25 | + opacity: 1, |
| 26 | + icon: { |
| 27 | + iconUrl: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3wsIFR0j2j5hUQAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAADElEQVQI12P4//8/AAX+Av7czFnnAAAAAElFTkSuQmCC', // Transparent pixel |
| 28 | + iconSize: [0, 0], // size of the icon |
| 29 | + popupAnchor: [0, 0] // point from which the popup should open relative to the iconAnchor |
| 30 | + }, |
| 31 | + message: "<button ' \ |
| 32 | + ng-click='setSourceMarker()'>First button</button> \ |
| 33 | + <button class='btn btn-danger btn-block' \ |
| 34 | + ng-click='setDestinationMarker()'>Second button</button>", |
| 35 | + getMessageScope: function () { |
| 36 | + return $scope; |
| 37 | + }, |
| 38 | + }; |
| 39 | + }; |
| 40 | + |
| 41 | + $scope.$on("leafletDirectiveMap.click", function (event, args) { |
| 42 | + var leafEvent = args.leafletEvent; |
| 43 | + var lat = leafEvent.latlng.lat; |
| 44 | + var lng = leafEvent.latlng.lng; |
| 45 | + |
| 46 | + $scope.markers.popup.lat = lat; |
| 47 | + $scope.markers.popup.lng = lng; |
| 48 | + $scope.markers.popup.focus = true; |
| 49 | + |
| 50 | + }); |
| 51 | + |
| 52 | + angular.extend($scope, { |
| 53 | + chicago: { |
| 54 | + lat: 41.85, |
| 55 | + lng: -87.65, |
| 56 | + zoom: 8 |
| 57 | + }, |
| 58 | + markers: { |
| 59 | + popup: getNewPopupMarker(41.85, -87.65) |
| 60 | + } |
| 61 | + }); |
| 62 | + }]); |
| 63 | + |
| 64 | + </script> |
| 65 | +</head> |
| 66 | +<body ng-controller="MarkersCompiledWithoutIconController"> |
| 67 | + <leaflet lf-center="chicago" lf-markers="markers" height="480px" width="100%"></leaflet> |
| 68 | + <h1>Changing Icon Rotation</h1> |
| 69 | +</div> |
| 70 | +</body> |
| 71 | +</html> |
0 commit comments