I used Qgis2Web and I'm really a beginner. Is there a way can I highlight a feature using their coordinates? I'm currently developing a website which suggests location based from pre-defined inputs. And the only thing i have is the lat and lon. I hope these helps :)
-
2Can you explain in a little more detail? Do you mean have users type in long/lat into a field, and features at that location on the map are highlighted? Or do you mean you want to specify the long/lat in your map code?– Tom ChadwinOct 5, 2017 at 10:24
-
I'm currently developing a website which suggests a location based from the pre-defined inputs. And the only thing i have is the lat and lon. I hope these helps :)– RheenaOct 5, 2017 at 12:15
1 Answer
qgis2web exports all layers as geoJson so you have all your features available. You could use map.forEachFeatureAtPixel method passing your coordinates as the pixel parameter. The hard part so is to modify the javascript files exportet by qgis2web.
So actually I would recommand to use QGIS server and load the layers as WMS or WFS layers:
On WMS layers you can access and highlight the features with getGetFeatureInfoUrl passing your coordinates as a parameter. This example may give you some hints.
On WFS layers you can access and highlight the features with forEachFeatureAtPixel passing your coordinates as the pixel parameter. This example may give you some hints.