Skip to content

Commit

Permalink
fix(registration): show marker on map in registration
Browse files Browse the repository at this point in the history
Show marker again during registration
  • Loading branch information
mpfeil committed Jan 31, 2018
1 parent e18ab75 commit ac28553
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 13 deletions.
2 changes: 2 additions & 0 deletions app/components/leaflet.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
'selectedBoxMarker': L.featureGroup().setZIndex(1000),
'mobileTrajectory': L.featureGroup(),
'mobileMeasurements': L.featureGroup(),
'registration': L.featureGroup(),

'markerCluster': mcg,
// adding to map adds all child layers into the parent group for subgroups
Expand Down Expand Up @@ -156,6 +157,7 @@
mapLayers['activeMarkers'].clearLayers();
mapLayers['inactiveMarkers'].clearLayers();
mapLayers['oldMarkers'].clearLayers();
mapLayers['registration'].clearLayers();
for (var markerId in newVal) {
var markerOpts = newVal[markerId];
var marker = L.marker(markerOpts.latLng, markerOpts);
Expand Down
1 change: 0 additions & 1 deletion app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ angular
progressbar.start();
return OpenSenseMapAPI.getBoxes({params: {classify: true}})
.then(function (data) {
console.log(data);
progressbar.complete();
return data;
})
Expand Down
59 changes: 47 additions & 12 deletions app/scripts/controllers/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,16 +300,19 @@
if (Object.keys(vm.markers).length === 0) {
vm.markers = {
box: {
'layerName': 'registration',
'latLng': [parseFloat(args.latlng.lat.toFixed(6)),parseFloat(args.latlng.lng.toFixed(6))],
'lat': parseFloat(args.latlng.lat.toFixed(6)),
'lng': parseFloat(args.latlng.lng.toFixed(6)),
'draggable': true,
'icon': {
markerColor: 'green'
}
'draggable': true
}
};
} else {
vm.markers = angular.copy(vm.markers);
vm.markers.box.latLng = [
parseFloat(args.latlng.lat.toFixed(6)),
parseFloat(args.latlng.lng.toFixed(6))
];
vm.markers.box.lat = parseFloat(args.latlng.lat.toFixed(6));
vm.markers.box.lng = parseFloat(args.latlng.lng.toFixed(6));
}
Expand All @@ -318,6 +321,10 @@

$scope.$on('osemMarkerDragend.map_register', function(e, args) {
vm.markers = angular.copy(vm.markers);
vm.markers.box.latLng = [
parseFloat(args.target._latlng.lat.toFixed(6)),
parseFloat(args.target._latlng.lng.toFixed(6))
];
vm.markers.box.lat = parseFloat(args.target._latlng.lat.toFixed(6));
vm.markers.box.lng = parseFloat(args.target._latlng.lng.toFixed(6));
vm.editMarkerInput = angular.copy(vm.markers);
Expand All @@ -328,19 +335,22 @@
if (Object.keys(vm.markers).length === 0) {
vm.markers = {
box: {
'layerName': 'registration',
'latLng': [parseFloat(args.latlng.lat.toFixed(6)),parseFloat(args.latlng.lng.toFixed(6))],
'lat': parseFloat(args.latlng.lat.toFixed(6)),
'lng': parseFloat(args.latlng.lng.toFixed(6)),
'draggable': true,
'icon': {
'markerColor': 'green'
}
'draggable': true
}
};
if (args.latlng.altitude) {
vm.markers.box.height = parseFloat(args.latlng.altitude.toFixed(2))
}
} else {
vm.markers = angular.copy(vm.markers);
vm.markers.box.latLng = [
parseFloat(args.latlng.lat.toFixed(6)),
parseFloat(args.latlng.lng.toFixed(6))
];
vm.markers.box.lat = parseFloat(args.latlng.lat.toFixed(6));
vm.markers.box.lng = parseFloat(args.latlng.lng.toFixed(6));
}
Expand Down Expand Up @@ -457,23 +467,48 @@
if (Object.keys(vm.markers).length === 0) {
vm.markers = {
box: {
'latLng': [parseFloat(newValue.lat.toFixed(6)),parseFloat(newValue.lng.toFixed(6))],
'lat': parseFloat(newValue.lat.toFixed(6)),
'lng': parseFloat(newValue.lng.toFixed(6)),
'height': newValue.height,
'draggable': true,
'icon': {
'markerColor': 'green'
}
'draggable': true
}
};
} else {
vm.markers = angular.copy(vm.markers);
vm.markers.box.latLng = [
parseFloat(newValue.lat.toFixed(6)),
parseFloat(newValue.lng.toFixed(6))
],
vm.markers.box.lat = parseFloat(newValue.lat.toFixed(6));
vm.markers.box.lng = parseFloat(newValue.lng.toFixed(6));
vm.markers.box.height = newValue.height;
}
vm.editMarkerInput = angular.copy(vm.markers);
}
});

$scope.$watchCollection('register.newSenseBox.exposure', function (newValue, oldValue) {
if (newValue === '') {
return;
}

if (newValue === 'indoor' || newValue === 'outdoor') {
var icon = 'cube';
var color = 'green';
}

if (newValue === 'mobile') {
var icon = 'rocket';
var color = 'blue';
}
vm.markers = angular.copy(vm.markers);
vm.markers.box.icon = L.AwesomeMarkers.icon({
type: 'awesomeMarker',
prefix: 'fa',
icon: icon,
markerColor: color
});
});
}
})();

0 comments on commit ac28553

Please sign in to comment.