Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zoom to features with a max scale constraint #4897

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

nboisteault
Copy link
Member

No description provided.

@nboisteault nboisteault added backport release_3_9 run end2end If the PR must run end2end tests or not labels Oct 21, 2024
@github-actions github-actions bot added this to the 3.10.0 milestone Oct 21, 2024
@Gustry Gustry added sponsored development This development has been funded javascript Pull requests that update Javascript code labels Oct 22, 2024
@nboisteault nboisteault force-pushed the zoom_to_feature_max_scale branch 5 times, most recently from 69fc9de to 6fde4c4 Compare October 24, 2024 14:08
@nboisteault nboisteault marked this pull request as ready for review November 12, 2024 10:40
Copy link
Collaborator

@rldhont rldhont left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove lizMap from LocateByLayer module.

Comment on lines +19 to +22
constructor() {
this._locateByLayerConfig = lizMap.config.locateByLayer;
const locateBtn = document.getElementById('button-locate');
if (mainLizmap.initialConfig.locateByLayer) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
constructor() {
this._locateByLayerConfig = lizMap.config.locateByLayer;
const locateBtn = document.getElementById('button-locate');
if (mainLizmap.initialConfig.locateByLayer) {
/**
* Build the lizmap LocateByLayer instance
* @param {LocateByLayerConfig} locateByLayer - The lizmap locateByLayer config
* @param {WfsFeatureType[]} vectorLayerFeatureTypeList - The list of WFS feature type
* @param {Map} map - OpenLayers map
* @param {object} lizmap3 - The old lizmap object
*/
constructor(locateByLayer, vectorLayerFeatureTypeList, map, lizmap3) {
this._map = map;
this._vectorLayerFeatureTypeList = vectorLayerFeatureTypeList;
this._lizmap3 = lizmap3;
this._lizmap3LocateByLayerConfig = lizmap3.config.locateByLayer;
const locateBtn = document.getElementById('button-locate');
if (locateByLayer) {

Comment on lines +33 to +35
for (var lname in this._locateByLayerConfig) {
if ('order' in this._locateByLayerConfig[lname])
locateByLayerList[this._locateByLayerConfig[lname].order] = lname;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (var lname in this._locateByLayerConfig) {
if ('order' in this._locateByLayerConfig[lname])
locateByLayerList[this._locateByLayerConfig[lname].order] = lname;
for (var lname in this._lizmap3LocateByLayerConfig) {
if ('order' in this._lizmap3ocateByLayerConfig[lname])
locateByLayerList[this._lizmap3ocateByLayerConfig[lname].order] = lname;

var locateContent = [];
for (var l in locateByLayerList) {
var lname = locateByLayerList[l];
var lConfig = lizMap.config.layers[lname];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var lConfig = lizMap.config.layers[lname];
var lConfig = this._lizmap3.config.layers[lname];

var lname = locateByLayerList[l];
var lConfig = lizMap.config.layers[lname];
var html = '<div class="locate-layer">';
html += '<select id="locate-layer-' + lizMap.cleanName(lname) + '" class="label">';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
html += '<select id="locate-layer-' + lizMap.cleanName(lname) + '" class="label">';
html += '<select id="locate-layer-' + this._lizmap3.cleanName(lname) + '" class="label">';


var featureTypes = lizMap.mainLizmap.initialConfig.vectorLayerFeatureTypeList;
if (featureTypes.length == 0) {
this._locateByLayerConfig = {};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this._locateByLayerConfig = {};
this._lizmap3LocateByLayerConfig = {};

this.getLocateFeature(lname);
}
$('.btn-locate-clear').click(function () {
lizMap.mainLizmap.map.clearHighlightFeatures();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
lizMap.mainLizmap.map.clearHighlightFeatures();
this._map.clearHighlightFeatures();

*/
zoomToLocateFeature(aName) {
// clear highlight layer
lizMap.mainLizmap.map.clearHighlightFeatures();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
lizMap.mainLizmap.map.clearHighlightFeatures();
this._map.clearHighlightFeatures();

Comment on lines +399 to +405
lizMap.mainLizmap.map.setHighlightFeatures(data.features[0], "geojson");
}).fail(function(){
lizMap.mainLizmap.map.setHighlightFeatures(feat, "geojson");
});
}
// zoom to extent
lizMap.mainLizmap.map.zoomToGeometryOrExtent(geom);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
lizMap.mainLizmap.map.setHighlightFeatures(data.features[0], "geojson");
}).fail(function(){
lizMap.mainLizmap.map.setHighlightFeatures(feat, "geojson");
});
}
// zoom to extent
lizMap.mainLizmap.map.zoomToGeometryOrExtent(geom);
this._map.setHighlightFeatures(data.features[0], "geojson");
}).fail(function(){
this._map.setHighlightFeatures(feat, "geojson");
});
}
// zoom to extent
this._map.zoomToGeometryOrExtent(geom);

}
$('#locate .menu-content').html(locateContent.join('<hr/>'));

var featureTypes = lizMap.mainLizmap.initialConfig.vectorLayerFeatureTypeList;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var featureTypes = lizMap.mainLizmap.initialConfig.vectorLayerFeatureTypeList;
var featureTypes = this._vectorLayerFeatureTypeList;

@@ -167,6 +168,7 @@ export default class Lizmap {
this.legend = new Legend();
this.search = new Search();
this.tooltip = new Tooltip();
this.locateByLayer = new LocateByLayer();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.locateByLayer = new LocateByLayer();
this.locateByLayer = new LocateByLayer(
this.initialConfig.locateByLayer,
this.initialConfig.vectorLayerFeatureTypeList,
this.map,
this._lizmap3
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport release_3_9 javascript Pull requests that update Javascript code run end2end If the PR must run end2end tests or not sponsored development This development has been funded
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants