Is there a way to use Leaflet and Geocoder together?

Events happening in the community are now at Drupal community events on www.drupal.org.
orkutmuratyilmaz's picture

Hello Spatial Drupalists,

I'm trying to geocode city names and show it on leaflet map, at the node add/edit forms. Is there a way to do it?

Thanks for your kind help:))

Comments

Do you instantly want to show

Sinan Erdem's picture

Do you instantly want to show the map in the edit form when the user enters a city? Or show the point on a Leaflet map after the node saved?

If first, then I dont know a solution with Leaflef but I did it with Geolocation module. It has a nice widget where you can enter a city name, and it points the city in the map right away. Unfortunately the stored result is only stored as lat,lon pairs. I didn't find a way to save actual text input by the user. Maybe it can be done with some JS to store the text in that field onto another text field on the fly.

If you want the second one, you can use an address field in the edit form to collect the city information. Then you can use Geocoder to convert this field into Geofield. You can later use this Geofield with Leaflet.

We need first option to build

orkutmuratyilmaz's picture

Actually we thought about second option yesterday as Plan B, so as Turks said "The path of inteligence is one":))

We're going to try your suggestion for first scenario. Thanks for your kind help&cooperation:)

First option tested with success

boragunesdogan's picture

It works!

We installed Geolocation module with Google Maps submodule enabled. Editor can insert a placemark by either entering text or mouse click.

A better solution could be ...

boragunesdogan's picture

We realized that we were losing geofield functionality and decided to use an input widget for geofield. So Geolocation Google Maps module was dropped in favor of Geofield Gmap module. This new one provides an autocomplete geocoder with geofield support. We used Leaflet Views module for displaying markers.

Location and Mapping

Group organizers

Group categories

Wiki type

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: