Using Location+Gmap I was used to automatic geocoding based on my address but then I was also able to move the pinpoint in the map to a more accurate position (and IIRC Location was storing also the map zoom).

So, while editing an entity I'd like to have a map and be able to specify if I want it to be automatically geocoded or if I want to set a specific position on the map, or something similar.

This issue will be fixed in the geofield module here #1627940: Add optional geocoding to map input widget Please review and post there!

Comments

thlor’s picture

I think Conditional Fields may be a dirty but working solution.

hnln’s picture

Geofield has the same request: http://drupal.org/node/1308510

michaelfavia’s picture

@thlor: are you using conditional fields to expose the geofield map input and disable the geocoding?

@hnln: This is an interesting suggestion/request. Geofield stores the WKT/LATLON and openlayers is the input widget you seek. I've often run into the same issue and would like this functionality myself.

As the inheritor of this module I am interested to know if a "refine geolocation option" might be valuable to reexpose the geofield imput map if we already have a location stored or something similar. Thoughts?

bago’s picture

@michaelfavia the "refine geolocation option" could be a good improvement. The best thing at all would be to have geocoding to happen in ajax and to automatically locate the point in a map widget and then use the map widget to submit a point (and if you don't have ajax/javascript then you revert to allow geocoding on save and refine later or simply choose the location on the map on the first save and not use geocoding at all). I don't know how doable this is, but I guess this is what people used to location+gmap expect.

michaelfavia’s picture

@bago: thx for feedback

Ok then. Lets say we go ajax route. We currenlty geocode from pictures, files with gpx info, address_fields and regular text fields. Ar eyou proposing that we only perform the ajax look up on lose focus of the textfeilds and address fields? Ping the geocoder service on the lose focus event of each text area?

What happens if you adjust the point on the map further by hand and then update your address field (be it body, addressfield, or other) after that? Does it revert tyour map point or keep your manual adjustment.

bago’s picture

This is a good question. I'd say that once you changed it "by hand" then geocoding should not change it anymore. But then it would be good to have a way to say "forget my custom location and start automatically geocoding again!"

I don't know how things are currently stored (I didn't dig the code or the db for this issue) so I don't know if you currently have a way (once saved and reloaded) to know if the coordinates have been automatically geocoded or if they have been manually inserted pinpointing a map.

hnln’s picture

I'm not a fan of the ajax approach as geocoding should happen in hook_field_attach_presave as otherwise you don't get any geocoding when you programatically save, batch save (vbo) or import content with addresses (and those are quite common to import :-), see also http://drupal.org/node/1297654 and http://drupal.org/node/1417078.

I'm also not a big fan of the location approach, it cluttered the form too much (address fields, map, some explanations a checkbox to delete location that confused people, ...).

'Refine geolocation' sounds good to me :-) Maybe a checkbox as mentioned in the geofield issue and if checked the form will display again on submit but this time it will also show the map widget. We should make sure then that the automatical geocding doesn't happen when map widget is used and a way to remove it as well.

bago’s picture

@HnLn: I hoped we could get on the fly AJAX support while retaining the features for the vbo/import/presave.

The use case is that you are adding a new node, you enter the street/city and then you want to know ASAP if the geocoding know what you are talking about, otherwise you have to manually set the position. If you don't use AJAX you ask users to save and look at the result, edit to refine and save again. It is a lot of work if geocoding fails often (I saw it failing 30% of cases in my current site, and another 30% needs refinement anyway.)

pribeh’s picture

Ya, we had this setup on a d6 client site and the real advantage for users was when they were able to see immediate results, ie ajax. The user needs to see the map locate based upon text field address input and vice a versa immediately, otherwise this is not a useful feature. This is the same reason autocomplete is so handy. Like bago alludes to, this is about reducing user error.

okeedoak’s picture

I agree: use ajax but keep vbo/import/presave.

phayes’s picture

These should be two different widgets: first-widget should be as-in, the second-widget can be ajax.

phayes’s picture

Category: support » feature
phayes’s picture

The first step is to do this: #1462364: Provide AJAX service

phayes’s picture

Now that we have our AJAX service we can proceed.

Long-term we need to wait until this issue is resolved in geofield: #1273802: Geofield/Openlayers widget refactor as we would want to base any really good, general purpose interactive widget on geofield's new openlayers map widget.

However, short-term I would be willing to accept a patch that does google maps to get SOMETHING in place. This should go in a new sub-module. (Called geocoder_interactive ??)

pribeh’s picture

@phayes #14, what about using leaflet? project/leaflet

phayes’s picture

Leaflet would also be great. It looks like they have a feature-request out for a widget: #1284932: Leaflet field input widget . Once they build a widget perhaps we can riff off it for our geocoder powered version.

pribeh’s picture

K, I'll see if I can get some to help jump start on the widget.

henrijs.seso’s picture

In general idea - geocoding + manual adjustment in one form - is good, because it would potentially allow feeding changes back to geocoding providers.

I think editing address would do re-geocode, since address can be changed significantly, some smart proximity check could be made to determine severity of address change or default behavior would be set by field settings.

mieg’s picture

i tried using conditional fields but didn't get it to work. How would you do this? i made a 'geolocated' field and tried to update the location field when this was filled, but wasn't able to fill it with the value of the dependee.

phayes’s picture

Title: Geocode address OR allow user to move the pinpoint in a map » Interactive geocoding widget
nedjo’s picture

I hadn't found this issue before I implemented a workaround in #1585804: Optionally support direct digitizing of locations, using hook_field_widget_properties_ENTITY_TYPE_alter() to dynamically switch the widget through an AJAX call. Possibly that approach could be generalized, but there would be a number of issues. E.g., getting the settings required for the different widgets would be difficult.

nedjo’s picture

The workaround in #1585804: Optionally support direct digitizing of locations works but has a lot of moving parts.

To reduce the complexity I sketched in a possible approach in #1627940: Add optional geocoding to map input widget.

My thinking is:

  • If we're combining a map digitizing widget with a geocoding one, the map is primary. A particular location may be geocoded, but if it's been manually edited the manual edit is what we want to keep. In future edits, we won't want to programmatically repeat geocoding, because doing so would discard manual changes. In short, the geocoding is an optional step prior to manual digitizing. Therefore, geocoding functionality makes most sense as an optional enhancement to a map-based widget.
  • The data processing in geocoder involves a complex interplay of widget settings and field processing to e.g. selectively concatenate fields prior to geocoding. Rather than reproduce this logic on the client side, it would be preferable to reuse the existing server side handling. So rather than writing a new openlayers behaviour, we should look to AJAX form submission with selective element replacement.

Not sure how sound either of these points are. Happy for comments and review.

Also posted two related issues:

giorgio79’s picture

1. Related issue, probably this issue would be dependent on this as well: #1461164: Reverse-Geocode support
Adjusting the marker manually on a map would require reverse geocoding, since the mapping service needs to provide an address based on lat long..

2. Sometimes, an ambiguous address field input may yield multiple results on the map. A "Did You Mean" feature would be great as well, for example:
http://econym.org.uk/gmap/didyoumean.htm

phayes’s picture

We will be tackling this issue in geofield here: #1627940: Add optional geocoding to map input widget, not in geocoder module. All comments etc should go there. I will keep this issue open as a pointer

phayes’s picture

Status: Active » Fixed

This is now fixed. See geofield module.

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

sdf