Closed (fixed)
Project:
Geolocation Field
Version:
8.x-1.x-dev
Component:
Geolocation field
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
4 Mar 2016 at 19:02 UTC
Updated:
28 Dec 2016 at 22:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
malcomio commentedI've made a start on this - it feels quite hacky, and there's a lot of scope for improvement, but it kind of works...
Comment #3
malcomio commentedComment #4
malcomio commentedImproved the patch - if the locality matches the post town, don't duplicate them
Comment #13
malcomio commentedHEAD is also failing: https://www.drupal.org/node/241478/qa
Comment #14
derjochenmeyer commentedGreat, thanks! Lets wait to get more eyes on this one.
Comment #15
pcambraI've tested #4 and works great for my use case, but probably is a bit of a biased implementation.
I'm attaching a new patch that adds the lookup when positioning the marker.
We probably want to make this more generic and probably extensible by following something similar to #1040640: Store and display geocoded address information AND/OR address data entered by users and adding a setting in the geolocation field to match which address field (or any other module for that matter) should be updating.
I think this patch as it is will update every address field in the edit screen.
Comment #16
zerolab commentedRe-roll for #15 to handle the yet to be initialized geocoder.
Comment #17
edysmpReroll for #16
Comment #18
edysmpAdded support for city and state.
Comment #19
NetNerdy commentedhi, thank you very much for your nice works.
where can i set the "address" module as data-storage on geolocation field module? (see attached image)
i am working on localhost, drupal 8.1.1, php 7 and also the patch #18
thank's
Comment #26
christianadamski commentedThis needs another re-roll. Anybody? :)
Comment #27
heddnReroll
Comment #28
christianadamski commentedComment #29
derjochenmeyer commentedWhat happens if Address Field is not present / installed?
Should there be any settings? Not that I think we need settings. Simplistic solutions are good. Didn't have a chance to test the patch but it looks nice and clean.
Comment #30
heddnre #29: I thought about that when I was re-rolling this. I think what happens is the jquery selector fails to find address module's fields and doesn't insert them. One thing to consider is if there are multiple address module fields on the edit form. We could have a configuration to select which one. But I feel like that type of complexity can go into a follow-up. This gets ball rolling, is simple to review and we can add functionality later.
Comment #31
christianadamski commentedI'm working on it :)
Comment #32
christianadamski commented- moved geocoding functionality to separate library
- added resultCallback() functionality to geocoder
- removed geocodingWidget specific code in geocoder
- wired up resultCallback in geolocation-widget-geocoder.js
- added settings to geocoding widget to select address field
- added handling of selected field to geolocation-widget-geocoder.js
- fixed 'controlls' typo
- fixed independent issue of map not loading in geocoding widget
- some minor issues
- TODO: preparation work is there, to store the address in a hidden form and save it in Drupal later. This would allow to completely hide the address field and still get it populated.
Please test.
Comment #33
christianadamski commented- Re-roll against HEAD
- fixed an issue where map would not load in geocoder widget on new content
- added a lot more JS documentation, drastically reducing ES Lint warnings
Comment #38
christianadamski commentedOops, empty patch
Comment #43
christianadamski commented- missing schema added
Comment #45
christianadamski commentedCommitted. I think this is progress. Also allows some nicer handling of other issues.
Comment #46
NetNerdy commented@ChristianAdamski
the function doesn't work -> geolocation address-field doesn't take on the data from address-module (field_address).
working on localhost, Drupal 8.1.3, php 7, last geolocation-update 8.x-1.x-dev from July 27, 2013 - 10:34
when i add the address-data manually is anything fine -> but that's not the idea by this patch/function ;)
settings in content-type:
- address-module required and have this fields: addressLine1, postalCode, locality and country (only one country is available, e.g. Germany)
- Geolocation Google Geocoder -> Geocoded address will be stored in field_address
settings in address-module:
- Postal code type -> Postal Code
- Locality type -> City (also tested with Post town)
Set the Google API-key and all needed Google API's are enabled.
Whats wrong in my settings?
Thanks a lot for your help!
Comment #47
christianadamski commented@NerdyCrowd,
this is probably a mis-understanding. Right now this widget only works in one specific way:
when editing the content, there is the geolocation field present with geocoding widget AND the target address field defined in the geolocation widget settings is present with the default address widget.
Selecting an address in the geocoder widget should then set the values in the address widget.
That hidden form with address values you see there, is just part of a TODO. I would like to extend the functionality when I find time for that, but tight now that hidden form is entirely useless. Maybe I should remove it for now...
Does this help?
Comment #48
christianadamski commentedComment #49
NetNerdy commented@ChristianAdamski
Thank you very much for this explanation. So, there is - at the moment - no benefit for our users after implementing the geolocation field module.
we need address-data in two ways:
1. as description of a location, e.g. address from a building - this is seen for all users
2. as submission/data-value for maps - the map is seen for the users
in this case, our editors have to write "double" the address-data, right?
hmmm...ok...this is really a misunderstanding in this patch/extension.
Ok...now...perhaps...is there any way or idea to solve this problem?
the following could be a wonderful functionality (i think):
the data-value from the address-module will take over in the geolocation-module (address-field).
exists a planning in this direction?
...by the way...the leaflet-module give us a solution. leaflet take over the address-data from address-module to printing-out a map...but leaflet-maps are not so common and nice like google maps in geolocation-module...and...leaflet isn't under intense development like geolocation
;) ?
Thank's in advance!
Comment #50
dkre commented@NerdyCrowd
I can't quite understand how this patch doesn't satisfy your needs.
If you have the geolocation pre-populate the address then there isn't any need for manual input into the address field.
-
@ChristianAdamski, This patch works really well - nice work. The only issue is it doesn't work for multi-value fields. I would perhaps document this limitation when this is commited.
Comment #51
NetNerdy commented@ChristianAdamski...thank you very much for your work!!!
now, the geolocation field prepopulates the address field (address-module: address line 1, postal-code, locality).
When i mark the address (address-module) as required, then address fields will NOT prepopulating.
And...the (german) address-format isn't right after prepopulating. geolocation fills in "address line 1" at first the streetNumber and as second the street. the right way is 1. street, 2. streetNumber. I don't know if this managed by geolocation (autofill processing) or in address module. (see attachment)
Thanks for any help!
Comment #52
malcomio commented@NerdyCrowd I think it would make sense to create a separate issue for the specific bug that you've observed.
Comment #53
NetNerdy commented@ ChristianAdamski / malcomio
i have locate the one issue - (german) format in address line 1, in:
geolocation/js/geolocation-widget-googlegeocoder.js
line 166 - changed
from:
addressLine1 = streetNumber + ' ' + route;
to:
addressLine1 = route + ' ' + streetNumber;
but...the other issue (address as required) i haven't a solution...
I don't know "How to create a patch..." ...so i can write it here only.
Comment #54
mstef commentedNot working for me with latest dev. Searching via the geolocation field widget does not pre-populate the Address field (despite it being set in the form settings).
Actually, when I set a linked Address field in the form settings, I am no longer able to select an address in the Geolocation field.
Getting these:
Uncaught TypeError: Cannot read property 'replace' of undefined (line 126)
I think there's a disconnect in the JS settings:
// JS looks for it
var targetField = drupalSettings.geolocation.widgetSettings.addressFieldTarget;
// PHP sets it
$element['map_canvas']['#attached']['drupalSettings']['geolocation']['widgetSettings'][$canvas_id]['addressFieldTarget'] = $settings['target_address_field'];
JS is missing the $canvas_id
Changing the JS to: var targetField = drupalSettings.geolocation.widgetSettings[map.id].addressFieldTarget; clears the error, but the functionality still does not work.
Comment #55
mstef commentedContinuing from above, in order to get the functionality to work, I remove the first and last two lines of:
After that, the mapping is incorrect.
I had to change the administrative mapping to:
The city was also always being added to address 2. I had to remove the extra initial ! from: if (!!locality && locality !== postalTown) {
Comment #56
mstef commentedPatch for the changes in 54 and 55.
Comment #57
mstef commentedOne more issue to fix.. Some places (like in NYC) do not return a locality/city but instead a neighborhood. This change will use that if there is no locality.
Also had to fix some logic that I mentioned above regarding the locality check.
Comment #58
mstef commentedComment #59
mstef commentedActually I'm removing the assignment of locality to address2 completely. I can't see how that's helpful.
Also setting premise to address1 if there is no street or route. This may be another NYC thing..
Comment #60
mstef commentedRemoved a console.log line.
Comment #62
christianadamski commentedHey mstef,
I altered the google geocoder widget to disconnect it more from the upcoming geocoder plugin stuff. Therefore your patch won't apply right now.
Can you re-apply your patch against current -dev and ensure it works as expected? I will then happily commit it.
Comment #63
christianadamski commentedFixed in #2835910: Google Geocoder Widget cleanup & extension
I incorporated most of @mstef and @NerdyCrowd's work there.
Comment #64
christianadamski commented