I failed to find the way to use leaflet map as input widget for geofield. Is it planned?

Comments

levelos’s picture

Category: task » feature

At some point, definitely. No timeline available at this point.

pribeh’s picture

I'm going to see if I can get someone to look at building this soonish.

pribeh’s picture

Also, this may be of interest to anyone checking out this issue queue: http://drupal.org/node/1393246#comment-5699892

mgifford’s picture

Issue tags: +Geofield

I brought this up elsewhere and it was marked as a duplicate #1734594: Geofield widget type

danielbeeke2’s picture

I have started working on an input widget see the duplicate issue -> http://drupal.org/node/1734594

chi’s picture

Title: Field input widget? » Leaflet field input widget
Status: Active » Needs review

Here is our solution. I think we should collaborate and maintain it as part of the Leaflet module.
http://drupal.org/sandbox/Chi/1796796

pvhee’s picture

Nice work! It would be good if the sandbox by danielbeeke (https://drupal.org/sandbox/GoalGorilla/1792420) and that of Chi (http://drupal.org/sandbox/Chi/1796796) could be merged, and promoted to a full project that relies on Leaflet.

I believe this is better than having it part of Leaflet, so we don't bloat the module for people that do not need the widget and make maintenance easier.

pvhee’s picture

An issue to look at is #1627940: Add optional geocoding to map input widget. Geocoding in combination with a map widget would definitely make sense, and I would love to see this working out-of-the-box with Leaflet (in a Leaflet Widget/Geocoder/Geofield combination).

danielbeeke2’s picture

I think we should fix this by creating/contributing to two leaflet plugins. Leaflet.draw is a good one for the input elements and for geocoding I have seen a bing version. I personnaly like google geocoding a lot more.

I will work on some spec ideas and post them here

chi’s picture

Leaflet formatter is a part of the Leaflet so I still think it's not a good idea to keep input widget out of the Leaflet module.

I've added @pvhee and @danielbeeke to the list of Leaflet widget maintainers.

pvhee’s picture

Chi, I understand that it might make sense to have them integrated, but I believe the strength of Leaflet when compared to the much more feature-rich OpenLayers in Drupal is the fact it is slim. It does one thing - displaying the map - and does it well, either using formatters, either using Views.

Adding to that the part of actually interacting with the mapping by adding new vectors (points, polygons, etc) is a completely different thing and requires a neat UX experience. Keeping the maintenance of these two things separate will allow it to evolve much faster. Then, at some point these could be merged I guess, but after they've had critical review from the community as a separate project. Does that make sense?

chi’s picture

Status: Needs review » Postponed

Ok, let's start a separate project.

levelos’s picture

Status: Postponed » Fixed

Thanks for the moving this important feature forward. FWIW, I support the separate module approach in order to keep Leaflet true to it's design goals of being a lightweight base to build mapping solutions with. Not every use case requires an input widget. Would make sense to move this ticket into the new project when it's created.

danielbeeke2’s picture


Leaflet input formatter

I think we should make something like the following specs:

Widget requirements (in order of importance):

  • Create a marker
  • Multiple on one entity
  • Geocode/reverse geocode (integrate with geocoder and addressfield)
  • Create a polygon
  • Create a rectangle
  • Create a circle (is this possible? WKT does not have a circle)

Default widget settings:

  • Default center
  • Default JSON options
  • Default zoom level
  • Default leaflet module API map
  • Width and height

You can add ideas to the google docs document,

https://docs.google.com/document/d/1zCVZ_SISAdKBDUjQjJgz_4JJN__mw41THpoh...

hawkbreeze’s picture

Now it looks like we have 3.

  1. danielbeeke https://drupal.org/sandbox/GoalGorilla/1792420
  2. tnightingale http://drupal.org/sandbox/thegreat/1802616
  3. Chi http://drupal.org/sandbox/Chi/1796796

Has a new project been created or are the creators of these sandboxes still doing there own thing? I noticed Daniel's last commit had "onwards..." in the commit message that was dated on the 3rd Oct.

Thanks

danielbeeke2’s picture

I will work further on it next week,
Had a busy week.

I pulled the new widget from tnightingale and some things a different, will look into it and see if we can work together.

tnightingale’s picture

Hey guys, yeah I recently committed some work I've done on a Leaflet.draw based widget to my sandbox. However most of my work has been going on here https://github.com/thegreat/Leaflet.widget.

My plan is to provide a Drupal-independent handler that binds to a html element (<input>/<textarea>/etc) and reads/writes GeoJSON to the element. Leaflet has excellent support for loading GeoJSON via the L.GeoJSON layer. My widget code extends this by converting markers, polylines, polygons (currently without holes) and their multi-equivalents back into GeoJSON.

Right now I am working on a 'select' tool to go alongside the other Leaflet.draw provided controls. Selected features will have actions performed on them. I'm currently working on a 'remove' action but I could also see the possibility for 'grouping' (creating multi-* geometries or GeometryCollections) or 'moving' features.

The idea for the Geofield integration is to minimize redundant parsing & generation of WKT/GeoJSON on both the client and the server. The widget only needs to expose a hidden input field (already handled by Geofield/FAPI) and have it bound it to a new Leaflet.widget handler. Upon form submission, the Leaflet.widget handler outputs it's features to GeoJSON and writes them into the input field, much like how the wysiwyg modules work. The data is then processed by Geofield's existing GeoJSON support.

I have been actively working on this as we need these features for some upcoming client work though I am open to collaborating with others who share similar interests and/or needs.

danielbeeke2’s picture

It is exactly the same in functionality, could you pull my sandbox and check it out?

We should merge the module and apply for a full version soon.

tnightingale’s picture

I have had a read though the code in your sandbox. It looks like it currently only supports POINT geometries. You're right though, there is overlap on the Drupal side of things. As I mentioned above, my focus is on stabilizing the Leaflet plugin which has full support for all primitive geometry types and partial support for complex ones.

My suggestion is that we merge the Drupal code (FAPI widget declaration, widget settings form; base layer, default center & zoom, & other settings) and adapt it to work with Leaflet.widget. You can view a functional demo here http://dl.dropbox.com/u/48433/Leaflet.widget/example/Leaflet.widget.html.

EDIT: I've updated the demo mentioned above and the README associated with the Leaflet.widget repository. Select and remove buttons are now working ...mostly ;).

ajmartin’s picture

Just thought I'd throw in my 2 cents worth... In whatever form this project progresses, I think it would be nice to have:

  1. the map center on users location (html5)
  2. configurable input settings. Ie. the site administrator should be able to determine what methods of input a user has available (create a marker, &/or polygon, &/or line). In this way, if a use case only requires a single pin on a map the UI is not cluttered with unnecessary buttons.

Thanks for your work on this project!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

tnightingale’s picture

For those still following along, I've promoted my sandbox to a full release: http://drupal.org/project/leaflet_widget. Feedback welcome/wanted! :)

hawkbreeze’s picture

Great! I'll test it and submit feedback on the project page. Thanks.