Skip to content

Multiple locations per item#66

Open
jimsafley wants to merge 13 commits intomasterfrom
feature/multi-location
Open

Multiple locations per item#66
jimsafley wants to merge 13 commits intomasterfrom
feature/multi-location

Conversation

@jimsafley
Copy link
Copy Markdown
Member

@jimsafley jimsafley commented Apr 29, 2026

Items can now have more than one location. Each location has an optional label, and the item edit form uses Leaflet.draw to add, reposition, and delete markers. All map views have been updated to reflect this. Includes a database migration.

Breaking changes

This feature requires a major version bump (4.0) due to some breaking changes:

  • API geolocations field — the shape of this field in the items API response has changed to support multiple locations per item.
  • Table_Location::findLocationByItem() — removed and replaced by findLocationsByItem() to support multiple locations per item.

Existing API consumers and any code calling these methods directly will need to update.

Cleanup

Several pieces of holdover code have been removed:

  • KML browse map pipeline — introduced for the Google Maps API, which could load KML natively. After the migration to Leaflet it survived as a custom jQuery XML parser. Replaced with a JSON endpoint.
  • map_type — a database column and API field from the Google Maps era, later repurposed to track which mapping library was in use. Once Google Maps support was dropped it was always 'Leaflet' and served no purpose.

Items can now have any number of named locations. The admin edit form
uses a Leaflet.draw toolbar to add, reposition, and delete markers.
Each marker has an optional label editable via popup. The browse map,
item show pages, exhibit map blocks, and static site export all reflect
multiple locations.
The multi-location rewrite broke the pre-existing behavior of
initializing the edit map at the item's saved coordinates and zoom.
For single-location items the saved zoom is now respected. For
multi-location items fitBounds overrides the center on tab select.
The multi-location rewrite dropped the panTo call after adding a
geocoded marker, so the map no longer moved to the found location.
Switch from single-resource format (id/url) to multi-resource format
(count/url) to support items with multiple locations. Adds item_id as
a whitelisted index param with applySearchFilters support so the url
is resolvable.
Leaflet.draw is needed on the item edit form and the contribution
form. Loading it globally is not ideal but matches the existing
approach for Leaflet itself.
Adds a button to every map (browse, item show, item edit) that fits all
markers in the viewport. Translatable strings for the control are passed
from PHP to JS via the options object.
@jimsafley jimsafley requested a review from zerocrates April 29, 2026 19:01
KML was a Google Maps era holdover, never a natural fit for Leaflet.
A dedicated browseJsonAction() now serves browse-json.php, moving
marker HTML assembly to PHP where Omeka helpers are available.
Removes the KML route, context switch filters, and ~80 lines of
client-side XML parsing.
Before multi-location support, the item marker was placed at the map
center via center.show. That was replaced by the options.points loop.
Inline and remove the now-single-use _getCenter() helper.
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