Description
Provides a widget for Drupal text fields with autocomplete suggestions from the Google Places API.
Also you can use the autocomplete path it defines for your own FAPI implementation.
Git Repo
git clone --branch 7.x-1.x http://git.drupal.org/sandbox/mariancalinro/2493761.git google_places_api_autocomplete
Sandbox
https://www.drupal.org/sandbox/mariancalinro/2493761
More complex use case example
1. Create a text field, and use the widget provided by this module on that field.
2. Using the Geocoder and Geofield modules,create a geofield on the same entity, and geocode a value to be stored in the geofield based on the text field from above.
3. Use the Openlayers module, which provides a formatter for the geofield from the previous field. This will show the geocoded feature described in the field from 1. on a map.
Advantages over using alternative solutions, such as Addressfield:
- Ease of use, you don't have to jump from field to field, no ajax requests when changing the country.
- Speed, the user will input his address in a shorter time.
Disadvantages over using alternative solutions, such as Addressfield:
- The address is not formatted, you can't extract only the country, or only the street address, at least not easily.
- External dependecy, it uses Google's Places API.
- If the website is quite large, it could go over the free quota of Google's Places API, and a fee would be required to use this solution.
Similar sandboxes
If found 2 sanboxes that have some degree of shared functionality, here they are, and some comments:
[D7] City Autocomplete - Is a couple years old, with no activity, the code has issues. Has a similar approach.
Google Places for Drupal- Is a sandbox, has a different approach, where the input is the Google Places ID, so the user must know it beforehand.
Comments
Comment #1
vincenzo gambino commentedHi,
please, replace mariancalinro@git.drupal.org:sandbox/mariancalinro/2493761.git with http://git.drupal.org/sandbox/mariancalinro/2493761.git
Also fix some error reported by Pereview http://pareview.sh/pareview/httpgitdrupalorgsandboxmariancalinro2493761git
Comment #2
mariancalinro commentedComment #3
mariancalinro commentedThanks Vicenzo
I updated the git url.
From the pareview.sh list, I set up a default branch, and I fixed some of the line length errors in README.md.
However, there are 2 issues that are reported by preview.sh that I feel should be ignored. namely:
1.It is reporting that the function places_autocomplete() should be renamed to be prefixed by the module name. However, the autocomplete functions from core & contrib that I know of have the naming pattern RESOURCE_NAME_autocomplete. Taking this into consideration I feel this should be ignored.
2.In the readme files there is an URL longer than 80 characters (88 to be exact). If i brake this into 2 lines, some editors that automatically convert URLs in links will have a broken link. Again, I feel this should be ignored.
Comment #4
PA robot commentedWe are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)
Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #5
everright commentedHi mariancalinro,
I have test the module on drupal 7, add new field to node type with one or more numbers setting, it was worked fine.
PAReview
1. FILE: google_places_api_autocomplete/README.txt
---------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------
75 | WARNING | Line exceeds 80 characters; contains 88 characters
---------------------------------------------------------------------------
I think url so long may be no problem, but for my suggestion is remove the hashtag from the url, just "https://developers.google.com/places/webservice/autocomplete" also very clearly to get places api notes.
2. places_api_autocomplete.module: all functions should be prefixed with your module/theme name to avoid name clashes. See https://www.drupal.org/node/318#naming
For the function "places_autocomplete", I think you need to rename it, your module functions should be prefixed with your module name, my suggestion is rename function name to "_places_api_autocomplete", also update on hook_menu.
Suggestions
1. variable name
It was not reported by pareview, but rename variable name "places_api_options" to "places_api_autocomplete_options" is good option.
2. Two README file (README.md, README.txt)
I think one file enough, you can merge it.
3. Remove variables when module uninstall.
4. PHP Notice when variables not saved yet.
Notice: Undefined index: offset in places_api_autocomplete_admin_settings() (line 38 of places_api_autocomplete.admin.inc).
Notice: Undefined index: location in places_api_autocomplete_admin_settings() (line 43 of places_api_autocomplete.admin.inc).
Notice: Undefined index: radius in places_api_autocomplete_admin_settings() (line 48 of places_api_autocomplete.admin.inc).
Notice: Undefined index: language in places_api_autocomplete_admin_settings() (line 53 of places_api_autocomplete.admin.inc).
Notice: Undefined index: types in places_api_autocomplete_admin_settings() (line 58 of places_api_autocomplete.admin.inc).
Notice: Undefined index: components in places_api_autocomplete_admin_settings() (line 63 of places_api_autocomplete.admin.inc).
Suggestion: Add default value when module install or use isset to check key exist in options array.
Comment #6
vedpareek commentedHello
Mannual review
1. Please fix pareview.sh issues http://pareview.sh/pareview/httpgitdrupalorgsandboxmariancalinro2493761git
2. All functions should be prefixed with your module name.
3. Line exceeds 80 characters; contains 88 characters in Readme.md
Comment #7
vedpareek commentedComment #8
mariancalinro commentedRegarding #5:
#6 touches the same issues as #5, so these are resolved as well. Setting as needs review.
Comment #9
pablitt commentedHi mariancalinro!
Manual review:
hook_install()in your .install file, take a look at the recommended practices.$documentation_link = 'https://developers.google.com/places/documentation/autocomplete#place_autocomplete_requests';two times. Maybe you want to move that to a more common place as a constant, or maybe aplaces_api_documentation_linkDrupal variable, that way it would be easier if the link changes and then you'll be able to use a hook update to change the variable. In that case, you can set the initial value in the install hook :)includes/ApiAutocompleteCacheServiceInterface.phpon line 5 says* Contains ~~., you should change that to* Contains PlacesApiAutocompleteCacheServiceInterface..Other than that, looks good to me :)
Good and detailed info in the issue page and the project page.
Nice module, congrats :)
Comment #10
klausi@pablitt: that are nice tips for improvements but surely not application blockers, anything else that you found or should this be RTBC instead?
Comment #11
pablitt commentedI think 1, 3 and 5 should be addressed. 4 Is only a suggestion :)
Thanks!
Comment #12
ajay_reddyHello,
I have test the module on drupal 7, worked fine.
Mannual review
1. Please fix pareview.sh issues http://pareview.sh/pareview/httpgitdrupalorgsandboxmariancalinro2493761git
2. Found issues in coder module.
places_api_autocomplete.module
severity: criticalreview: security_fapi_titleLine 182: Potential problem: FAPI elements '#title' and '#description' only accept filtered text, be sure to use check_plain(), filter_xss() or similar to ensure your $variable is fully sanitized. (Drupal Docs) [security_fapi_title]
'#title' => $instance['label'],
Comment #13
mariancalinro commentedIssues #9.1 #9.3 #9.4 #9.5 and #12.2 have been taken care of.
remaining issues in pareview.sh are:
1. Line exceeds 80 characters; contains 88 characters. As per #8 and #9, I will leave it as it is.
2. In hook_install I set a confirmation message that is not translated. The reason is hook_install can be executed without a db connection, so the translation would have to be in a po file. Also, this is the only time the message will be shown, so it is highly unlikely that anyone will translate this. I will leave it as it is for now.
Comment #14
klausiReview of the 7.x-1.x branch (commit 2ce7bd5):
This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.
manual review:
But otherwise looks good to me.
Comment #15
klausino objections for more than a week, so ...
Thanks for your contribution, mariancalinro!
I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.
Here are some recommended readings to help with excellent maintainership:
You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!
Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
Thanks to the dedicated reviewer(s) as well.