Skip to content
Snippets Groups Projects
Commit 9fda5d5f authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

[fix] Map: fix map click event

parent c37a97fd
No related branches found
No related tags found
No related merge requests found
.leaflet-top {
top: 44px !important;
}
.legend { .legend {
font: 14px/16px Arial, Helvetica, sans-serif; font: 14px/16px Arial, Helvetica, sans-serif;
background: rgba(255,255,255, 0.9); background: rgba(255,255,255, 0.9);
......
...@@ -22,7 +22,6 @@ angular.module('cesium.map.plugin', ['cesium.services']) ...@@ -22,7 +22,6 @@ angular.module('cesium.map.plugin', ['cesium.services'])
$stateProvider $stateProvider
.state('app.view_wot_map', { .state('app.view_wot_map', {
url: "/wot/map?lat&lng&zoom", url: "/wot/map?lat&lng&zoom",
cache: false,
views: { views: {
'menuContent': { 'menuContent': {
templateUrl: "plugins/map/templates/wot/map.html", templateUrl: "plugins/map/templates/wot/map.html",
...@@ -40,8 +39,6 @@ angular.module('cesium.map.plugin', ['cesium.services']) ...@@ -40,8 +39,6 @@ angular.module('cesium.map.plugin', ['cesium.services'])
esGeo, UIUtils, MapData, leafletData) { esGeo, UIUtils, MapData, leafletData) {
'ngInject'; 'ngInject';
$scope.loading = true;
var constants = { var constants = {
FRANCE: { FRANCE: {
lat: 47.35, lng: 5.65, zoom: 6 lat: 47.35, lng: 5.65, zoom: 6
...@@ -49,6 +46,8 @@ angular.module('cesium.map.plugin', ['cesium.services']) ...@@ -49,6 +46,8 @@ angular.module('cesium.map.plugin', ['cesium.services'])
}; };
constants.DEFAULT_CENTER = constants.FRANCE; constants.DEFAULT_CENTER = constants.FRANCE;
$scope.loading = true;
$scope.mapId = 'map-wot-' + $scope.$id;
$scope.map = { $scope.map = {
center: angular.copy(constants.DEFAULT_CENTER), center: angular.copy(constants.DEFAULT_CENTER),
defaults: { defaults: {
...@@ -118,17 +117,23 @@ angular.module('cesium.map.plugin', ['cesium.services']) ...@@ -118,17 +117,23 @@ angular.module('cesium.map.plugin', ['cesium.services'])
$scope.stateName = state && state.stateName; $scope.stateName = state && state.stateName;
$scope.stateParams = angular.copy(state && state.stateParams||{}); $scope.stateParams = angular.copy(state && state.stateParams||{});
var center = angular.copy(constants.DEFAULT_CENTER); var center;
if (state.stateParams) { if (state.stateParams) {
if (state.stateParams && state.stateParams.lat) { if (state.stateParams.lat) {
center = {};
center.lat = parseFloat(state.stateParams.lat); center.lat = parseFloat(state.stateParams.lat);
} }
if (state.stateParams && state.stateParams.lng) { if (state.stateParams.lng) {
center = center || {};
center.lng = parseFloat(state.stateParams.lng); center.lng = parseFloat(state.stateParams.lng);
} }
if (state.stateParams && state.stateParams.zoom) { if (state.stateParams.zoom) {
center = center || {};
center.zoom = parseFloat(state.stateParams.zoom); center.zoom = parseFloat(state.stateParams.zoom);
} }
if (center) {
center = angular.merge({}, constants.DEFAULT_CENTER, center);
}
} }
$scope.load(center); $scope.load(center);
...@@ -139,8 +144,6 @@ angular.module('cesium.map.plugin', ['cesium.services']) ...@@ -139,8 +144,6 @@ angular.module('cesium.map.plugin', ['cesium.services'])
}); });
$scope.load = function(center) { $scope.load = function(center) {
center = center||constants.DEFAULT_CENTER;
$scope.loading = true; $scope.loading = true;
// removeIf(no-device) // removeIf(no-device)
...@@ -212,13 +215,9 @@ angular.module('cesium.map.plugin', ['cesium.services']) ...@@ -212,13 +215,9 @@ angular.module('cesium.map.plugin', ['cesium.services'])
}, {}); }, {});
$scope.map.markers = markers; $scope.map.markers = markers;
angular.merge($scope.map.center, center);
$scope.loading = false; leafletData.getMap(/*$scope.mapId*/).then(function(map) {
UIUtils.loading.hide();
leafletData.getMap().then(function(map) {
// Control: search // Control: search
L.control.search({ L.control.search({
layer: markersLayer, layer: markersLayer,
...@@ -256,8 +255,16 @@ angular.module('cesium.map.plugin', ['cesium.services']) ...@@ -256,8 +255,16 @@ angular.module('cesium.map.plugin', ['cesium.services'])
}); });
}).addTo(map); }).addTo(map);
var needCenterUpdate = center && !angular.equals($scope.map.center, center);
if (needCenterUpdate) {
//angular.merge($scope.map.center, center);
$timeout(function() {
map.invalidateSize(); map.invalidateSize();
map._resetView(map.getCenter(), map.getZoom(), true); map._resetView(center, center.zoom, true);
}, 300);
}
$scope.loading = false;
UIUtils.loading.hide();
}); });
}); });
}; };
...@@ -266,7 +273,7 @@ angular.module('cesium.map.plugin', ['cesium.services']) ...@@ -266,7 +273,7 @@ angular.module('cesium.map.plugin', ['cesium.services'])
$ionicHistory.nextViewOptions({ $ionicHistory.nextViewOptions({
disableAnimate: true, disableAnimate: true,
disableBack: true, disableBack: true,
historyRoot: true historyRoot: false
}); });
$scope.stateParams = $scope.stateParams || {}; $scope.stateParams = $scope.stateParams || {};
......
<ion-view left-buttons="leftButtons">
<ion-nav-title>
<leaflet id="map-wot" </ion-nav-title>
<ion-nav-buttons side="secondary">
</ion-nav-buttons>
<ion-content data-tap-disabled="true">
<leaflet
height="100%"
center="map.center" center="map.center"
markers="map.markers" markers="map.markers"
layers="map.layers" layers="map.layers"
controls="map.controls"> controls="map.controls">
</leaflet> </leaflet>
</ion-content>
</ion-view>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment