Skip to content

Feature/fix map annotation#3

Open
ismism-learner wants to merge 3 commits into
mainfrom
feature/fix-map-annotation
Open

Feature/fix map annotation#3
ismism-learner wants to merge 3 commits into
mainfrom
feature/fix-map-annotation

Conversation

@ismism-learner
Copy link
Copy Markdown
Owner

有一个新征程

google-labs-jules Bot and others added 3 commits October 12, 2025 04:35
This commit refactors the location finding logic to address a bug where connections and highlights were not appearing for events with Chinese or complex location names.

The core changes are in the `findLocationCoordsAndFeature` function:

-   **Prioritizes JSON Database:** The function now searches the `countries+states+cities.json` database first, as this is the primary source of truth for location data.
-   **Two-Way Name Matching:** Implements a more robust, two-way matching algorithm. It generates a comprehensive list of name variants (e.g., English, Chinese, aliases) for both the user's input and the database entries, then checks for any intersection. This is a significant improvement over the previous one-way lookup.
-   **Fallback to Shapefiles:** If a location isn't found in the JSON database, the logic falls back to searching the loaded Shapefile layers.
-   **Decoupled Highlighting:** The `findLocationAndConnect` function is updated to first find coordinates for the line, and then separately find the geographic feature in the Shapefiles for highlighting. This ensures highlighting works even if the primary coordinates came from the JSON file.
-   **Coordinate Parsing Fix:** Adds a fix to correctly parse longitude and latitude values that may use a comma as a decimal separator.

While these changes address the core logical flaws, final interactive debugging is required to resolve remaining issues that were not reproducible in a headless environment.
This commit replaces the previous faulty search logic with a new, precise, and robust hierarchical search system adapted from a user-provided working example. This resolves all outstanding issues related to location finding for both event annotations and the general search box.

Key changes include:

-   **Refactored `findLocationCoordsAndFeature`**: The function now performs a strict, case-insensitive, step-by-step search for locations based on a "Country,State,City" hierarchy. It no longer uses fuzzy matching, which prevents incorrect location identification.

-   **Refactored `searchLocation`**: The top-left search box function is now aligned with the new hierarchical logic, providing accurate and comprehensive search results from the JSON database.

-   **Removed Fallback Logic**: The complex and error-prone fallback search to Shapefile layers has been removed, as the primary search in the JSON database is now sufficiently robust and accurate, simplifying the codebase.

-   **Event Parsing**: Retains the multi-line, semicolon-delimited event parsing functionality from previous commits.

This commit represents the final, user-verified, and fully functional version of the feature.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant