Closed (fixed)
Project:
Geofield
Version:
7.x-2.x-dev
Component:
GeoField Map
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
29 Jun 2016 at 16:49 UTC
Updated:
30 Nov 2018 at 15:04 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
giorgoskTemporary workaround
get an API key
https://developers.google.com/maps/documentation/javascript/get-api-key
and create your own module that overrides the JS of geofield
Comment #3
ashwinshHello @GiorgosK,
I have created a patch for this issue.
After applying this patch we will able to configure Google Maps API key from 'admin/config/content/geofield-mapkey'.
Please check it.
Thank you,
AshwinSh
Comment #4
ashwinshComment #5
mlanth commentedAttached is a patch for this issue. I have made it so users can choose whether they want to use an api key, or a 'for Work' client id. I also consolidated the URL used into one function where it generates the query string so that should anything change it can be changed in one place rather than both.
It will also provides a warning on the status report page if an api key or client id is not provided so that users are aware while not forcing them to add one since there is still a grace period in which keys are not required.
Comment #6
giorgosk@mlanth
there was already a patch before yours, why not use that one ? what is the difference from yours ?
Comment #7
mlanth commentedFew changes in mine compared to the previous.
Comment #8
RAFA3L commentedI have a collapsible map and by default is closed, before apply the patch it open but immediately appear the message "Oops! something went wrong", the same happened with the map in nodes. This is the expected problem without the key.
After apply the patch and set the key the map is working fine in nodes but doesn't in the collapsed.
Instead of apply the patch if I added the key by hand in the files "geofield_map_plugin_style_map.inc" and "geofield_map.module" and work fine in nodes and collapsed map.
I added it just after "//maps.googleapis.com/maps/api/js?sensor=false" in both files, like this
'//maps.googleapis.com/maps/api/js?sensor=false&key=asdasdasdasd'
I'll inspect the patch soon
Comment #9
RAFA3L commentedOk sorry, my problem has nothing to do with the Google key, I remember what I did to make it collapsible...
In geofield_map.js I changed these lines to make both globals:
"var map =" to "map = "
and
"var range =" to "range ="
Then in my JS I did this to refresh the map after toggle it:
I don't know if is the best way to make it to work in my case, but I will appreciate it if this is included in the next version.
Comment #10
jrbI tested the patch in #5, and it worked for me.
Comment #11
ashwinshHello @mlanth,
Thank you for updating patch file.
In addition your changes, I have added Private/Signing Key configuration with client id for 'Google Maps for Work'. Also I have added uninstall hook for deleting all config variables from database after uninstall this module.
@GiorgosK: Please review the latest patch for this.
Thank you,
Comment #12
GemQueen commentedpatch #11 works for me - thank you so much!
Comment #13
anas_maw commentedPatch #11 works for me also.
Thanks
Comment #14
mlanth commentedUpdate to patch #11 fixing the following:
Also not sure signature actually required, but left it in. I believe the signing key is only required for server side requests using Googles other apis (Geocoding api for example).
Comment #15
ashwinshUpdate to patch #14 fixing the following:
1. Moved the uninstall hook to geofield_map.install file.
2. Updated uninstall hook logic for deleting all config variables from database after uninstall this module.
3. Fixed following coding standards for this module (Though it not related to this issue I have fixed them in this patch)
File: geofield_map.module
File: geofield_map_plugin_style_map.inc
File: geofield_map.admin.inc
File: geofield_map.install
Line 1: @file block missingThank you,
Comment #16
pebosi commentedMove
to .module file instead of .admin.inc, then it's working for me.
Comment #17
ashwinshHello @pebosi,
I have added updated patch file to resolve this issue, please check it.
Thank you,
Comment #18
pebosi commentedWorks for me.
Comment #19
waqarit commented#5 has worked for me :)
Comment #20
cedrichillion commentedHi,
Thanks for fixing this. I applied #17, but, FYI, I also had to generate a new key for it to work.
It seems to me that there is also an issue on Google's end (more details here: http://stackoverflow.com/questions/32121445/google-maps-wont-work-when-a...).
Cheers
Comment #21
giorgosk@ashwin.shaharkar
I think the patch has to solve one problem not try to solve all possible problems
otherwise its not going to be committed so please consult with one of the maintainers
before persuing further your patch
For example I think you have to do this in a seperate patch
----------
3. Fixed following coding standards for this module (Though it not related to this issue I have fixed them in this patch)
----------
its definetelly one of the reason I am not going to try this patch and go with my own workaround
Comment #22
ashwinshWorking on suggestions.
Comment #23
ashwinshHello @GiorgosK,
As per your suggestions, I have updated new patch file. Please review.
Thank you,
AshwinSh
Comment #24
manuel garcia commentedThis looks good to me, can we get it in?
Comment #25
manuel garcia commentedAlso, looks like we're going to run into duplicated configurations on this, see geocoder for example #2024809: Allow using a google API key
Comment #26
aaronelborg commentedI'm trying to apply this patch (#23) and it's not working.
aaron@localhost:/var/www/html/mysite.com/sites/all/modules/geofield/modules/geofield_map$ git apply -v geofield_map-google_api_requires_key-2757953-23.patch
I get no output. No error message, no success message. Just a whole lot of nothing.
What am I missing?
Thanks.
EDIT: Ended up applying the patch manually and everything seems to work now. Not sure if I screwed something up or there were indeed actual issues with that patch but I was returning 404s on the geofield_map.js and GeoJSON.js after the manual application. Once i put those files in their proper place things worked. Weird.
Comment #27
ashwinshHello @AaronELBorg,
I have applied patch #23 with geofield's 7.x-2.3 version and it is cleanly applied. I have attached screenshot for your reference kindly check it once again.
Thank you,
AshwinSh
Comment #28
ShaneT commentedHi
I am unable to patch my module. Does anyone have a patched version of this module they can share with me?
Comment #29
sushantverma.it commentedTemporary patch, if any one using gmap module
/sites/all/modules/contrib/geofield/modules/geofield_map/geofield_map.module
+if(module_exists('gmap') && !empty(variable_get('gmap_api_key', ''))){
+ $key = '&key='.variable_get('gmap_api_key', '');
+ }
$element[0] = array(
'#attached' => array(
'js' => array(
- '//maps.googleapis.com/maps/api/js?sensor=false' => array('type' => 'external'),
+ '//maps.googleapis.com/maps/api/js?sensor=false'.$key => array('type' => 'external'),
drupal_get_path('module', 'geofield_map') . '/js/GeoJSON.js',
drupal_get_path('module', 'geofield_map') . '/js/geofield_map.js',
array('data' => array('geofieldMap' => $js_settings), 'type' => 'setting'),
),
May be this is helpful to anyone.
Comment #30
sunil s. commentedHi Guys, I am too facing this problem of Maps.
I am bit of confused here about google maps.
I am currently working on a project and showing map using geofield module. and it is giving some javascript error.
So, do I have to get different api key from google for all the enviornment i will use or just one will work.
e.g. currently I am working on local.dent.com,
I will geocode the address and save it
then I will move it to dent.example.com, and then finally to production.
So, for all the enviornment I will require different map api key. And also which one, as there are server key, browser key...lots of keys..
Thanks in advance.
Sunil
Comment #31
damienmckennaBump.
Comment #32
damienmckennaFYI I've built a new module (cod_nearby) that requires this patch in order to work.
Comment #33
barwonhack commentedApplied successfully #23 patch.
Suggest new release of Geofield.
Comment #34
fietserwinI applied the patch and tested it:
- patch applied cleanly
- status report: correct message about missing API key
- configured API key
- visited a page with a geofield map: both warnings (missing API key and Sensor) are gone, map shows correctly.
Conclusion:
- Problem solved with this patch.
- This patch also solves #2655438: Remove sensor parameter.
- I think (but did not test) that this patch also solves #2270733: Add support for Google Maps API for Business.
So +1 on RTBC.
However a few remarks:
- hook_menu does not need translated strings
- this patch could be smaller and less obtrusive by just using a variable and only define it to the variables module (soft dependency), so that the variables module can present a UI for it. This patch would typically only solve the problem at hand, not the other problems... In this case it could add a fallback to the geocoder variable (please with a "soft dependency" only!) as I guess that will often be already present.
So back to NW for the 1st remark.
Comment #35
damienmckennaI disagree that adding support for Variable module would be worthwhile, no need for the extra bloat.
This version of the patch improves hook_requirements so it only does the variable check when it's already installed, removes the translation on the menu item's title and description (as correctly identified by fietserwin), adds @file docblocks to the three files, fixes indenting in geofield_map_uninstall(), removes some errant blank lines in geofield_map.module.
Comment #36
fietserwinBack to RTBC:
1 small remark but that can be done on commit:
typo: Mmap instead of Map
Aside: IMO declaring a variable to the variables API gives less bloat: no admin.inc file and no hook_uninstall in this patch, just a hook_variables. But no need to change this patch again just for this.
Comment #37
fietserwinOops
Comment #38
damienmckennaWhoops, sorry for the typo.
And while you might think a small admin file and hook_uninstall is a lot, it's a lot less than installing a whole extra module.
Comment #39
fietserwinThanks for correcting.
Aside: I was talking about size of patch, not from the site builder standpoint and as I tend to build multi-lingual sites, the variables module is installed by default in our sites.
Comment #40
andrei.godea commentedBased on the patch from #38, I made some changes to add a new permission.
Comment #41
manuel garcia commentedI don't think this permission is that dangerous that site administrators should restrict access to this permission to trusted users.
It should be fine by just omitting this key and use the default of FALSE.
Comment #42
andrei.godea commentedGood ideea. I'm uploading the new patch and the new interdiff.
Comment #43
manuel garcia commentedThanks @andrei.godea - back to RTBC (assuming we do want a new permission).
Comment #44
simoncritchell commentedhello all!
i am writing because i see there are many postes and fixes for geofield... i am trying to get it to work but it seems the new google api causes problems... i was wondering is there a way i could get gpx track content to display using geocode, geofielp and geophp on a bing, or openlayers, or leaflet map instead of google ( in a simple and easy way ?)
any ideas?
cheers simon*
Comment #45
jmary commented#42 works and is compatible with the patch I have just posted at https://www.drupal.org/node/2673268
Comment #46
jmary commentedThis said openlayers with Google maps seems heavily broken, I have spent my day to reach something presentable, which in the end can be resumed in : Don't mess with openlayers if your focus in the end is Google maps.
Apply the patch here, and go to configure your display and your view(s) using geofield only.
Comment #47
simoncritchell commentedhello i am trying to patch the geofield module using terminal on osx..
here is what i get :
patching file b/modules/geofield_map/geofield_map.admin.inc
can't find file to patch at input line 80
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/modules/geofield_map/geofield_map.info b/modules/geofield_map/geofield_map.info
|index 204175a..b884aab 100644
|--- a/modules/geofield_map/geofield_map.info
|+++ b/modules/geofield_map/geofield_map.info
--------------------------
File to patch:
i have tried the -p0 like this : patch -p0 < geofield-google-api-key-2757953-42.patch and i am patching within the modules/geofield_map folder.. any advice here would be very welcome... first patch ever.... thanks simon*
Comment #48
simoncritchell commentedOr could someone share a patched module? somehow?
Comment #49
aaronelborg commentedSimon, I had an issue applying the patch as well.
I think there's some confusion with the version to which the patch applies.
Looking at the issue, the bug is with:
Version: 7.x-2.x-dev
Ashwin's patch, however, is for 7.x-2.3 version.
(see here):
I ended up manually applying the patch to my dev version and it worked.
Hope this helps somewhat.
Comment #50
jmary commented@simoncritchell
The rule on drupal is that patch apply with the -p1 option :
cd module_dir
patch -p1 < path_to_dir/file_name.patch
Comment #51
damienmckenna@simoncritchell: You also have to "cd" to the geofield directory first, e.g. "cd sites/all/modules/contrib/geofield".
Comment #52
barwonhack commentedIt would be great of someone willing and able could release a new version (2.4) of Geofield.
Comment #53
litonfiredesign commentedYes, that would be great #52, patch is definitely not one to apply manually at its scale.
So to get this straight, Iv added two keys to google maps api so far, one for the google side, one on my website in the code for the maps module, but I will need another for use of geofield?
Comment #54
tony decicco commentedI applied the patch to 7.x-2.3 version with the below output. Does it seem correct? What I am not clear on is where to apply the API key.
patch -p1 < ~/patches/geofield-google-api-key-2757953-42.patch
patching file modules/geofield_map/geofield_map.admin.inc
patching file modules/geofield_map/geofield_map.info
Hunk #1 succeeded at 3 with fuzz 1.
patching file modules/geofield_map/geofield_map.install
patching file modules/geofield_map/geofield_map.module
patching file modules/geofield_map/includes/geofield_map_plugin_style_map.inc
Comment #55
ericdsd commented+1 for RTBC
Comment #56
spanners commentedApplying patch #42 worked for me (just the patch, didn't need the other .txt file).
Applied to version 7.x-2.3, not the dev version.
After applying the patch, ensure you then go to the Geofield Map config page and add your Google Maps Javascript API there.
Comment #57
issa.haddadinPatch #42 is not working for some reason, i applied it on 7.x-2.3 and 7.x-2.x-dev on Drupal 7.51, i have an API key enabled and i added it to the geofield config page, i also made sure that the API key is working by the workaround on comment #2 (it worked on the input field but not on the node view page.)
Comment #58
damienmckenna@issa.haddadin: Did you try clearing your site's caches after applying the patch? The field output might have been be stuck in field cache.
Comment #59
damienmckenna@issa.haddadin: Also, which formatter are you using for the field?
Comment #60
issa.haddadinI'm really sorry, i got confused between 2 config pages that have a field for Google API Key, one from the Geofield Map module and another one from the Geofield Gmap, i added my key to the config page of the Geofield Gmap module not Geofield Map, and that's why it didn't work, when i changed it, the map worked.
I think Geofield Gmap module should get the key from Geofield Map module, no need for another config page, but that's another issue on Geofield Gmap module.
Again sorry about the confusion.
Thank you.
Comment #61
nico.bzh commentedHi,
Sorry for any mistake, I am new at Drupal.
I have applied the patch and it fixed the problem.
However, I now have an error while updating drupal. Could this be related? Has anyone else heard about this?
Error message while "Verify requirements" step
Here is the content of "geofield_map.info"
Comment #62
sohal khatwani commentedPatch #42 worked for me. Had to refresh the cache a couple of times and wait for a few minutes for Google's API to recognise the key.
Comment #63
barwonhack commentedOMG - someone please, for the sake of humanity, a new release! ;)
Comment #64
jboeger commented>> OMG - someone please, for the sake of humanity, a new release! ;)
Pretty please!!
Comment #65
aaronelborg commented@nico.bzh
Doesn't seem like the patch applied correctly (at least to your info file, anyway).
This is what my geofield_map.info looks like:
I updated my drupal version (and some other modules) and this all stopped working.
I played with it in short bursts for a good 2 days tweaking this and then tweaking that.
I ended up having to reapply the patch to 7.x-2.3 and things got really weird again.
I've got it working now but man... this issue is not for the faint of heart at all.
Comment #66
aaronelborg commentedAlso, FWIW...
Another interesting wrinkle in this seems to be that a node save gets things working now.
Perhaps that will help someone else.
Comment #67
chalk commented#42 works like a charm!
Comment #68
dale42#42 worked for me
Comment #69
biarr commented#42 worked for me too
Comment #70
guypaddock commentedSorry to be the bearer of bad news, but
hook_requirements()is not implemented properly. This patch causes site installs to fail on automated CI with the following errors:Comment #71
guypaddock commentedLet's try this one. This is a re-roll to ensure that
geofield_map_requirements()always returns an array for all phases.Comment #72
guypaddock commentedMoving to NR.
Comment #73
manuel garcia commentedThanks @GuyPaddock can you provide an interdiff to make it easier to review please?
Comment #74
chop commented@manuel-garcia please install https://dreditor.org/
It gives you all the tools you need to manage Drupal's issue queue and patches - inline diffs, etc
UPDATE dreditor is going away (Trump says: Sad!). Back to the old CVS workflow until the issue queue functionality improves.
Comment #75
manuel garcia commented@chOP I've been using dreditor for years. Also, it does not help with interdiffs between patches...
Comment #76
broonApplied #71 to Geofield 7.x-2.3 successfully without any errors:
Without entering a Google Maps Javascript API Key, it already resolves the Sensor warning message. Once the API Key was entered, no warning at all showed up in the browser console and all maps in a view showed up correctly.
Kudos to all contributing to this patch, which I think is ready for version 2.4.
Comment #77
broonForgot to attach the interdiff I made for checking the changes over the patch in #42.
Comment #78
jmary commentedPlease issue new release 2.4, because obviously the 2.3 is broken because of the present issue.
Comment #79
deadpoet commentedI can confirm the patch provided in #71 fixes the problem in Geofield v7.x-2.3 -- thank you, GuyPaddock.
Comment #80
marcmueller commentedHey, is there a patch for the views plugin as well?
Comment #81
Rob_Feature commentedI patched successfully using #71 and added my key, but display of the map thru views still fails with a 'no api key' error. (and as a side note, as of now the workaround in #2 doesn't work either)
Comment #82
Rob_Feature commentedSwitching back to 'needs work' since Views integration doesn't work and that is essentially the same issue as using the map in other places.
Comment #83
ggiakoumidakis commentedI have a site on production facing the same issue. I try to apply any patch I see in here but the files don't match... My site's path is: /sites/all/modules/geofield/modules/geofield_map and inside there, css, includes, js, .info, .module. No /modules/geofield_map/geofield_map.admin.inc found!!!! This must be an obvious one, since no one else mentioned it. Any quick help would be appreciated!!!
Comment #84
ggiakoumidakis commentedSo yes it was obvious, I had to create the files I couldn't find...!
Comment #85
socialnicheguru commentedI can't get geocoding to work anymore.
The api key is needed and I was able to enter it.
But while the addressfield prints in node dispaly, the geofield does not. It is not geocoding.
The only way that I got geocoding to work on my site was:
1. use addressfield_autocomplete
2. select the geofield widget 'fill from addressfield_autocomplete'
I think it is because addressfield_autocomplete actually takes the api and executes it correctly.
This is a short term work around for me as I would like to use geofield the way it was intended
I also don't think this is a geofield_maps issue. I think it is now a geofield issue.
Comment #86
thomasmurphy commentedI think google's changed something on it's API recently, perhaps try exploring this related geocoder issue
https://www.drupal.org/node/2789803
I recently had to change a geocoded field's settings to use the google geocoding service over https, which was working fine up until a few days ago. Selecting to log failed geocoding attempts is really useful, too.
Comment #87
frankdesign commentedPatch at #71 worked for me - thanks.
Note, in case any one else comes across this and they are having problems with GeoField and GeoField GMap on a new site, GeoField GMap also needs to be patched. The patch is available here.
Comment #88
xcusso commentedPatch #71 works perfect!
Comment #89
drupixI definitely agree with #2 and #21.
Comment #90
karimb commented#2 was for me the best solution !!!
Comment #91
sandiaras commentedapply #2, is the simplest solution
Comment #92
jose reyero commentedPatch #71 works nicely.
Comment #93
deggertsen commented#71 worked for me. Thanks!
Comment #94
Lord Pachelbel commented#71 worked for me, but only after I figured out that
Comment #95
specialcyn commented#71 worked for me! but now Google charges now for the use of maps and displays the message "only for development purposes" someone tried with another alternative to google maps for the sites in Drupal 7?
Comment #96
Lord Pachelbel commentedYou're probably seeing the "only for development purposes" message because you haven't attached a billing account to your API key. Create a billing account and attach it to your key and your maps will work again.
Google won't actually bill you unless you have a high-traffic website. For most websites the API is still free to use because Google gives everyone $200 worth of usage credit each month, and the number of API calls it takes to use up $200 worth of credit is pretty large — e.g. 100,000 static map loads, 40,000 directions calls, 40,000 geocoding calls, 40,000 geolocation calls, etc.
https://cloud.google.com/maps-platform/pricing/sheet/ has all the pricing details.
Comment #97
anganastra commentedHi I just read the tread, I am not a drupal developer. I have the same issue on https://www.formscaff.com/branches can anyone please help me on the steps of applying the patch that would work.
Thanks
Comment #98
damienmckennaThe instructions for applying a patch are at: https://www.drupal.org/patch/apply
In the meantime, here's a zip of the latest 7.x-2.x codebase with patch #71 applied.
Comment #99
specialcyn commentedThanks for the information Lord Pachelbel, one more question, do you know if each month the amount of traffic is restarted in the billing account or is it acumulative? and if you exceed how it notifies you, or how do you do the automatic payment or is it another discount method? .
it seems that the $ 200 is only for the first month :(
Comment #100
Lord Pachelbel commentedFrom the pricing page:
"Pricing for our core products is pay as you go and you only pay for what you use. You also get a recurring $200 credit on your billing account each month to offset your usage costs, and you can set usage limits to protect against unexpected cost increases."
Comment #101
specialcyn commentedLord Pachelbel...Thanks again!
Comment #102
s427 commentedI used the zipped version of the module provided in comment #98 and I can confirm that it works (tested on two D7 sites). Thanks!
Comment #103
owilliwoPatch #5 works for me.
I was just wondering, when will the next release be published ?
Cause right now, this issue is really annoying, as available API keys are now required by Google...
Comment #104
damienmckennaI suspect the module could use someone stepping up to help maintain it.
Comment #105
lias commentedI am using the 7x-1.2 version and hit this issue with maps displaying the error message. Google map api settings, billing are correct in console and on site.
I wonder will there be a patch for Geofield 7.x-1.x version?
Comment #106
nicholassI applied zipped version from comment #98(patch #71). I had to add Administrators to have permissions to the new `admin/config/content/geofield_map` configuration page. But after that and saving our API key, the maps are back up and working.
Comment #107
AustinLewis2155 commentedWhile applying the patch I come across multiple instances of the patch being unable to find the correct file to patch. I am able to redirect it to find the referenced file. But now that the patch has applied ( no errors) I am unable to find the new permission to enable to allow a place to enter the API key via the GUI. Can anyone help me out?
Comment #109
itamair commentedhi all ... I am just maintaining the D8 version of Geofield ... but had a look to this, that seemed quite old and hot one.
Just committed the #71 patch into dev.
I don't use this in D7 anymore that match.
May we change this into "reviewed and tested by the community" ???
And eventually deploy a new version with it?
Comment #110
alx_benjamin commentedTested, working
Comment #111
manuel garcia commentedIve not tested this recently, though I did test it way back, and looking at the amount of people reporting ok on this, I assume it should be safe to release.
Thanks a ton @itamair for stepping up!
Comment #112
damienmckennaThanks @itamair!
Comment #113
abhaloda2 commentedHi all.
I'm currently experiencing this problem. I have Geocoder, Geofield and Geofield_map installed. All modules are up to date and an API key can be entered into the Geofield_map module and the Geocoder module. Do I need the API key in both these modules or just one? Th above patches mentioned are probably not useful as the latest version of these modules allows the API key to be entered.
Any help is welcome.
Thanks
Comment #114
damienmckenna@abhaloda2: If there's a field for adding the Google Maps API key then fill it in, no need to debate the issue. The latest 7.x-2.4 version of this module has the fix included, so just configure the API via the settings page and your site should be work.
Comment #115
owilliwo@abhaloda2, if all your modules are up to date and API keys properly set, it should work properly.
Maybe flush your cache.
Or you can check what is the error/warning in your JS console.
Is the API key attached to the URL when calling Maps API ?
One more thing, Geocoding and Maps Javascript are two different APIs, so two differents keys.
Comment #116
webmastercolin commented#94 @lord-pachelbel, Where does one find the permissions for this config page? I checked user permissions and reports->permissions. Thanks.
Comment #117
Lord Pachelbel commented@webmastercolin It should be on /admin/people/permissions - see my uploaded screenshot Screenshot_2018-11-16.png
Comment #119
webmastercolin commentedI applied the patch in #71, entered my API key at admin/config/content/geofield_map and in the geofield configuration page and it is still not using the key. The custom module overriding the JS doesn't work either. Can I just hardcode the key into the module somewhere?