I've been facing a challenge with this interaction for some time now, and finding the appropriate solution seems quite daunting at the moment.
Recently, I created a map with basic points using GeoJSON format (generated with PHP & MySQL). I'm curious if it's feasible to display these rendered points in a separate div element outside the map?
For example:
https://i.sstatic.net/pJAQj.jpg
My query is as follows: Is it possible that when I click on an item from the list on the right side, the corresponding marker on the map automatically gets highlighted (as illustrated in the image above)?
Here is the code snippet that aids in generating the map and GeoJSON, but it only plots the points on the map panel.
var karta = L.tileLayer.wms("http://geoportal.dgu.hr/wms?", {
layers: 'DOF',
attribution: "http://geoportal.dgu.hr/ "
});
rasvjeta_kvar_hum = new L.geoJson(null, {
// more code here
});
$.getJSON("php/rasvjeta_kvar.php", function (data) {
// code for adding data to map layer
});
// Additional code snippets follow...
I have attempted to resolve this issue by following advice from this source, but haven't had much success so far.
Any guidance or pointers on how to proceed would be greatly appreciated. Thank you.
UPDATE
After making some progress (albeit not enough) towards completing my task, I came up with the following approach:
https://i.sstatic.net/Y4BHI.jpg
By implementing the code below, I managed to generate elements on the right panel; however, certain limitations still exist.
// Code block snippet...
I am interested to know if it's possible to iterate through PHP-generated GeoJSON using the following code:
// New code snippet...
Upon trying to loop through the GeoJSON using the revised code mentioned above, I encountered the following error message:
Uncaught TypeError: people.forEach is not a function
Attached below is the PHP code responsible for creating GeoJSON from MySQL:
UPDATE II
With the assistance of fellow collaborator ghybs, I successfully implemented some interaction between external items and map markers. However, clicking on items from the external list solely zooms me into the same marker location. Is there a way to make it such that clicking an item from the external list zooms me directly onto the corresponding marker on the map?
Refer to the provided picture for better visualization.
If further clarification is needed, feel free to ask!