Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: custom markers (LAN-773) #233

Merged
merged 12 commits into from
Nov 10, 2023
Merged

Conversation

barredterra
Copy link
Member

@barredterra barredterra commented Jul 18, 2023

Depends on alyf-de/frappe#16

Bildschirmaufnahme.2023-10-27.um.12.35.34.mov

Todo:

  • Rotation (try https://github.com/bbecquet/Leaflet.RotatedMarker/tree/master)
  • Add image URL to GeoJSON provide icon URLs via API
    This way we can change the icon without updating all the GeoJSON data.
  • Hide Custom Marker section for users who cannot edit the map
  • show correct icon while placing new marker
  • show correct rotation while placing new marker
  • show correct rotation while moving existing marker

Sorry, something went wrong.

@barredterra barredterra self-assigned this Jul 25, 2023
@barredterra
Copy link
Member Author

@marination this PR is ready. Could you give it a final review?

Known issues:

  • The custom icon shows only after the marker is placed
  • While moving a custom marker around, the custom icon temporarily loses its rotation

If you can think of a solution for these, I'd love to hear it. Otherwise, we can revisit this later.

@marination
Copy link
Member

marination commented Sep 20, 2023

@barredterra

  1. Make marker the icon before click (we could re-run this snippet on rotation change maybe, so that the icon before the marker is placed is also rotated)
    Essentially overwrite the controls.
var Marker=  L.icon({iconUrl: "/files/5a362498d26358.3248465915134977528618.png",
	iconAnchor: new L.Point(12, 12),
	iconSize: [24, 24],
});

L.DrawToolbar.include({
    getModeHandlers: function(map) {
      return [
        {
          enabled: this.options.polyline,
          handler: new L.Draw.Polyline(map, this.options.polyline),
          title: L.drawLocal.draw.toolbar.buttons.polyline
        },
        {
          enabled: this.options.polygon,
          handler: new L.Draw.Polygon(map, this.options.polygon),
          title: L.drawLocal.draw.toolbar.buttons.polygon
        },
        {
          enabled: this.options.rectangle,
          handler: new L.Draw.Rectangle(map, this.options.rectangle),
          title: L.drawLocal.draw.toolbar.buttons.rectangle
        },
        {
          enabled: this.options.circle,
          handler: new L.Draw.Circle(map, this.options.circle),
          title: L.drawLocal.draw.toolbar.buttons.circle
        },
       {
          enabled: this.options.circlemarker,
          handler: new L.Draw.Circle(map, this.options.circlemarker),
          title: L.drawLocal.draw.toolbar.buttons.circlemarker
        },
        {
          enabled: true,
          handler: new L.Draw.Marker(cur_frm.get_field("location").map, { icon: Marker }),
          title: 'Place custom marker'
        },
      ]
    }
});
  1. Rotate marker on drag (the "drag" event listener should call _applyRotation, but I can't figure it out)

@marination
Copy link
Member

The rest LGTM

@barredterra barredterra merged commit 6f607e5 into version-13-hotfix Nov 10, 2023
@barredterra barredterra deleted the custom-markers branch November 10, 2023 15:34
@barredterra
Copy link
Member Author

🎉 This PR is included in version 0.13.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants