[view/map] Make auto zoom configurable
This commit is contained in:
@@ -18,6 +18,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.data-map-container .editor select {
|
.data-map-container .editor select {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.data-map-container .editor .editor-options {
|
||||||
|
margin-top: 10px;
|
||||||
|
border-top: 1px solid gray;
|
||||||
|
padding: 5px 0;
|
||||||
|
}
|
||||||
|
|||||||
@@ -75,6 +75,11 @@ my.Map = Backbone.View.extend({
|
|||||||
<div class="editor-buttons"> \
|
<div class="editor-buttons"> \
|
||||||
<button class="btn editor-update-map">Update</button> \
|
<button class="btn editor-update-map">Update</button> \
|
||||||
</div> \
|
</div> \
|
||||||
|
<div class="editor-options" > \
|
||||||
|
<label class="checkbox"> \
|
||||||
|
<input type="checkbox" id="editor-auto-zoom" checked="checked" /> \
|
||||||
|
Auto zoom to features</label> \
|
||||||
|
</div> \
|
||||||
<input type="hidden" class="editor-id" value="map-1" /> \
|
<input type="hidden" class="editor-id" value="map-1" /> \
|
||||||
</div> \
|
</div> \
|
||||||
</form> \
|
</form> \
|
||||||
@@ -92,7 +97,8 @@ my.Map = Backbone.View.extend({
|
|||||||
// Define here events for UI elements
|
// Define here events for UI elements
|
||||||
events: {
|
events: {
|
||||||
'click .editor-update-map': 'onEditorSubmit',
|
'click .editor-update-map': 'onEditorSubmit',
|
||||||
'change .editor-field-type': 'onFieldTypeChange'
|
'change .editor-field-type': 'onFieldTypeChange',
|
||||||
|
'change #editor-auto-zoom': 'onAutoZoomChange'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
@@ -120,7 +126,7 @@ my.Map = Backbone.View.extend({
|
|||||||
// If the div was hidden, Leaflet needs to recalculate some sizes
|
// If the div was hidden, Leaflet needs to recalculate some sizes
|
||||||
// to display properly
|
// to display properly
|
||||||
self.map.invalidateSize();
|
self.map.invalidateSize();
|
||||||
if (self._zoomPending) {
|
if (self._zoomPending && self.autoZoom) {
|
||||||
self._zoomToFeatures();
|
self._zoomToFeatures();
|
||||||
self._zoomPending = false;
|
self._zoomPending = false;
|
||||||
}
|
}
|
||||||
@@ -130,6 +136,7 @@ my.Map = Backbone.View.extend({
|
|||||||
self.visible = false;
|
self.visible = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.autoZoom = true;
|
||||||
this.mapReady = false;
|
this.mapReady = false;
|
||||||
|
|
||||||
this.render();
|
this.render();
|
||||||
@@ -198,10 +205,12 @@ my.Map = Backbone.View.extend({
|
|||||||
this.features.clearLayers();
|
this.features.clearLayers();
|
||||||
this._add(this.model.currentDocuments.models);
|
this._add(this.model.currentDocuments.models);
|
||||||
}
|
}
|
||||||
if (this.visible){
|
if (action != 'reset' && this.autoZoom){
|
||||||
this._zoomToFeatures();
|
if (this.visible){
|
||||||
} else {
|
this._zoomToFeatures();
|
||||||
this._zoomPending = true;
|
} else {
|
||||||
|
this._zoomPending = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -244,6 +253,10 @@ my.Map = Backbone.View.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onAutoZoomChange: function(e){
|
||||||
|
this.autoZoom = !this.autoZoom;
|
||||||
|
},
|
||||||
|
|
||||||
// Private: Add one or n features to the map
|
// Private: Add one or n features to the map
|
||||||
//
|
//
|
||||||
// For each document passed, a GeoJSON geometry will be extracted and added
|
// For each document passed, a GeoJSON geometry will be extracted and added
|
||||||
|
|||||||
Reference in New Issue
Block a user