I'd like to provide a helper module (that may be able to adapted into gmap core in the future via a field-level on/off toggle).

This module watches out for node add/edit forms and scans for location fields. If some are found it adds them to the $form variable for easy reference, and adds an #after_build to add the buttons in (+ reference the javascript file to provide the front-end geocoding).

Please note this module won't work unless you check the 'Use a Google Map to set latitude and longitude' checkbox (location_usegmap variable) at /admin/config/content/location with the gmap module installed. A 'Find Address on Map' button will appear above each location field map. It will aggregate the provided fields together and send them off to Google Maps to geocode.

This should be compatible with the Google Maps API v3 version of Gmap, when it is released, in addition to being compatible with Google Maps API v2.

http://drupal.org/node/348062#comment-7086402

http://drupal.org/files/location_gmap_find_address-7.x-1.1.zip

Gmap Location Find on Map

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sydneyshan’s picture

Updated version attached (due to JS error on Drupal.t() function call)...

kaizerking’s picture

Hi Thanks for this module
How to disable location fields so that user cannot enter the values manually?

kaizerking’s picture

I am getting popup your address was not not found

sydneyshan’s picture

Hi kaizerking,

if you would like to hide any fields you can implement a hook_form_alter() function in your own module and change the fields '#type' value from 'text' to 'hidden'.

As for the popup, if Google can't find your address that's an issue with either Google or your address...

Kind regards,
Shannon

kaizerking’s picture

you mean to say it only picks up my address by IP ?
It is not picking up any address
I am expecting to pick up any address by the marker position

podarok’s picture

Status: Needs review » Fixed

#1 commited pushed to 7.x-2.x
will be tagged in next minor gmap release

Thanks sydneyshan

countrdd’s picture

Should this be centering the map to the location? Also. I have added a field called radius...would it be possible for this module to create a circle with x radius around the new marker?

podarok’s picture

Category: feature » task
Priority: Normal » Major
Status: Fixed » Needs work

good to see a simpletest tests for this module

countrdd’s picture

Quick Question. It was not working on my site. What I found was the Address Fields did not have a gmap-control class attached to them...

kaizerking’s picture

it still isn't working

podarok’s picture

sydneyshan’s picture

Thanks, podarok.

kaizerking, I think you're confused as to what this module does. It takes the address you have typed into the fields and requests Google to geocode it (retrieve a latitude and longitude). It does not reverse-geocode (ie take your marker location and turn it into an address).

countrdd, I'm not sure what your intended use-case is, but it sounds as if what you're trying to do is front-end theming related. Google Maps can be manipulated easily on the front-end using javascript and commands like setZoom(13). Searching around a centre point latitude and longitude is another mater, and is possible within the current Drupal tools/ecosystem.

kaizerking’s picture

Oh ok ,That's good clarification thanks,I thought this is a reverse geo coding module,
is there any possibility to reverse geocode location fields

sydneyshan’s picture

@kaizerking This could be a little more tricky as it will depend on which fields you have enabled/disabled for users to edit, and also what breakdown Google provides when returning a reverse-geocode address (ie does it break it down into state, country, street address, city that can be easily mapped to gmap's fields?).

I don't have a need for this functionality at present (all the content entry I've needed to do is for existing addresses that need geocoding) - if you have a need please feel free to extend my module - it has the framework there to add a second button and attach reverse geocoding functionality to it with minimal work. If you do so, I'd encourage you to test it against Google Maps API 2 & 3 as the existing module does.

kaizerking’s picture

Hi thanks for the encouragement,
I have been trying to locate ways and means to populate addressfield fields and location fields
I have searched drupal org an following are the results:
1. the implementation seems to be very simple. //drupal.org/node/1907686 Adma S has nicely implemented this you can read from this comment http://groups.drupal.org/node/137049#comment-458789 and also there are links to download the module which is on git.it uses jquery.jmapping.js
this module is stand alone, it means no dependency on any thing like geofield, goecoder, geophp or any other module
the only issue with this module is the code is clumsy and since it is not in drupal no upgrading is possible, the beauty is it works great in it is current state it is hard coded reverse geo code address field
There is another nice approach to reverse geocode is here Reverse Geocode Widget

The correct approach of GMap Module:
To provide a ‘reverse geo code widget’ to location and address field the same way as this module is generating points on map.

muddie’s picture

ANy update on this module?
I have the latest Dev version installed and the sub module enabled but I get no "Find Address" button at all.

podarok’s picture

#16 try to run tests(Testing module) for the module and go through debug messages links to see how it works and where

muddie’s picture

Tried over the weekend to get my Testing Module activated but there is some open_basedir problem on my server that won't let it activate. Tried talking to the hosts but they couldn't help so I'm not going to be able to run the tests.

podarok’s picture

try localhost webserver installation

vipconsult’s picture

The button is not showing.

Latest release

vipconsult’s picture

For everybody else.

The find Address button only shows for CCK field and not the built in Node Location implementation

webatelier’s picture

The Find Address button is showing up fine for me at the admin level and client (user) level,
but the map itself only shows when i am logged in as an admin ... (in the node/add screen that is)
Any ideas ?
Can't find any permission other than the 'GMap Location - View Node Map' and that one doesn't change anything

PowerSchill’s picture

Category: task » bug

If I use the location module to collect geo information for the node then it doesn't show the button during editing. However, If I manually add a location field it shows the button during editing. Is there something that can be done to fix that?

Mark Vincent Verallo’s picture

Any way to let it show up also for node location implementation?

devad’s picture

"Find address on map" button in location field added to taxonomy term doesn't show up.

In same installation "Find address on map" button in location fields added to nodes is visible.

Is "Find address on map" working only with node entity currently?

D7.22, Gmap 7.x-2.6, Location 7.x-3.0-rc1

sydneyshan’s picture

Hi devad,

Looking back at my originally submitted code it would seem the first hook_form_alter condition is to check if the form is a node_edit form.

isset($form['#node_edit_form']) && $form['#node_edit_form'] && variable_get('location_usegmap', 0)

if a better method of identifying a form that contains editable location fields were available it would be worth implementing. Perhaps you can use dpm($form) and identify a common variable that can be targeted?

I also note the code refers to 'und' frequently, however I believe this should be set based on language settings for the site/content being edited.

Are you happy to provide a patch?

devad’s picture

Hi Sydneyshan

Thank you for reply.

I'm just a Drupal beginner. Paches are not in my knowledge skills... yet.

Maybe someone else who understands the issue?

nightlife2008’s picture

I updated my location_gmap_find_address.js to properly detect the field's parent div ID.

thiago78’s picture

This is a very good patch... So bad I cant make it work! :/

Any idea about why it is not working? The buttons doesnt show anywhere... Is it because I need to configure anything before the seach button actually shows up?

All the best,
Thiago

thiago78’s picture

Oh, BTW, I am using the entryform module... and inserting the "location" field in the form, but no luck at all. :/

josebc’s picture

matthewmessmer’s picture

Issue summary: View changes

This may be a little untimely, but I was having the same problem as #22 with the map not showing up for different user roles, and, at least in my case, the solution was to set permissions related to "Location: Submit latitude/longitude".

JordiTR’s picture

First of all, Shannon, a million thanks for this small but wonderful improvement! :-)

I've found it on the Location issue where you presented it and then discovering that it was already on my site on the last Gmap upgrade I did, but I was not using it because I had no idea it was there!!! :-P

JordiTR’s picture

Now some technical issue. We require to find a better condition for localizing the form. I'm not a very proficient programmer but I can't understant why exactly on your line
isset($form['#node_edit_form']) && $form['#node_edit_form'] && variable_get('location_usegmap', 0)
you are calling 2 times $form['#node_edit_form'].

On the other hand this line forces on only being capable to have this feature when using Location on nodes. I think that on Drupal 7 there's no sense on using anything not fieldable, so I used the CCK version of Location sharing the same field instance on some node types and on users. Then with some form_alter hooks magic we can inherit user values on node creation location fields.

The point is your module doesn't detect if the field is on a user profile form. I've changed it to my use to

  if (isset($form['#node_edit_form'])
      ||
      ($form['#form_id'] == 'user_profile_form' || $form['#form_id'] == 'user_register_form')
      &&
      variable_get('location_usegmap', 0)) {

Probably is not very elegant and it's too adapted to my development, but, hey, it works! It would be necessary to find a more open approach that would allow to be able to attach this button to he map on each and every entity such location field could be inserted. If there is no a general key maybe an admin section where we could provide the name of the forms. I don't know, just looking for alternatives.

Nchase’s picture

latest dev shows the button but when it was clicked nothing happens. Is there any configuration at gmap / Location that needs to be set in order to make the geocoding work?

anpolimus’s picture

Assigned: Unassigned » anpolimus
Issue tags: +dcuacs2015
anpolimus’s picture

paravibe’s picture

Status: Needs work » Needs review
FileSize
1.02 KB

Everything works for me.
I have just added form-item class to the button wrapper for better UI (it's adds margin and padding).

anpolimus’s picture

This task also requires a test that will check if the button is axisted at content.

anpolimus’s picture

Test is already implemented.
I have just deleted code in test that requested to be deleted.

Valentine94’s picture

Status: Needs review » Reviewed & tested by the community

Looks nice, thanks!

The last submitted patch, 28: findlocationbuttonfix-1921872.patch, failed testing.

podarok’s picture

Status: Reviewed & tested by the community » Fixed

#40 committed and pushed
Thanks a lot.

  • podarok committed ecebeed on 7.x-2.x authored by anpolimus
    Issue #1921872 by anpolimus, nightlife2008, paravibe, Valentine94: Find...

Status: Fixed » Closed (fixed)

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

smurfxx’s picture

Button is not showing for me, maybe something is changed during last year?
I have the latest dev of this module, do I have to patch it?
EDIT: I'm trying to use it in a custom content.

EDIT2: I'm sorry, button is showed if I add a custom location field. I was editing the default location field that location module adds to every new content type (I don't know if it's a bug of location module...)

EDIT3: Anyway, button can't find any address location!

EDIT4: Now it works but I think you must do a better documentation... At the line 65 of location_gmap_find_address.js you could put an alert about the activation of geocoding feature at admin/config/content/location/geocoding (with relative precision) and then we could now that we have to activate the Google Maps Geocoding API from our personal API manager.
Anyway there is a bug, if I put an address field with a slah (/) geocoding doesn't work.

smurfxx’s picture

Status: Closed (fixed) » Active
smurfxx’s picture

Status: Active » Needs work
devad’s picture

Status: Needs work » Closed (fixed)

@smurfxx

This patch is committed and it works. So, I suppose this issue should be kept closed.

Better documentation (support request) and address field with a slash problem (bug) should both be sent as new issues.