IvanGlinkin / CCTV

Close-Circuit Telegram Vision revolutionizes location tracking with its open-source design and Telegram API integration. Offering precise tracking within 50-100 meters, users can monitor others in real-time for logistics or safety, redefining how we navigate our surroundings
GNU General Public License v3.0
2.37k stars 327 forks source link

Improved Frontend #29

Closed jaebee2 closed 4 months ago

jaebee2 commented 5 months ago

Upon reviewing the code, I've identified a few potential improvements and areas to address:

Memory Management:

The markers array is used to store references to markers added to the map. However, when markers are removed or the page is refreshed, these references are not cleared. This could lead to memory leaks over time, especially if the user frequently adds and removes markers. Consider implementing a mechanism to remove markers from the array when they are no longer needed.

Event Listener:

The updateMarker() function is intended to update the position of the marker when the map is moved. However, it currently only listens to the 'move' event, which may not cover all scenarios where the map view changes (e.g., zooming). Consider adding additional event listeners or using a more comprehensive event, such as 'moveend', to ensure the marker position is always updated correctly.

Tooltip Position:

The tooltip displaying the distance between markers is currently positioned at the location of the previous marker (prevMarker.getLatLng()). This may not always be ideal, especially if the markers are close together or the map is zoomed out. Consider adjusting the tooltip position dynamically to ensure it remains visible and doesn't overlap with other elements on the map.

Optimization:

The updateDistance() function iterates over all layers on the map to find and update the radius of the circle layer. This approach works but may become inefficient with a large number of layers. Consider storing references to the circle layers separately or using a more efficient method to access and update the relevant layer. Error Handling: There is currently no error handling implemented in the code. While the code appears to be straightforward, adding error handling can improve the robustness of the application and provide better feedback to users in case of unexpected issues. Implementing these improvements should enhance the functionality, performance, and reliability of the web application. Changes made:

jaebee2 commented 5 months ago

What do you think about this?

IvanGlinkin commented 5 months ago

Thanks a lot. Will look through it a little bit letter

levensonblaine commented 4 months ago

Yeah, I tested with 17k markers and the html report cannot be viewed because of lagging