Closed (fixed)
Project:
Simple Google Maps
Version:
3.0.0
Component:
Miscellaneous
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
7 Nov 2019 at 07:04 UTC
Updated:
19 Jun 2021 at 22:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
vivek panicker commentedComment #3
jhodgdonI think that is a good idea. At some point between when this module was first created and now, Google changed its map URLs. We should definitely update the module in both 8.x and 7.x.
As a note, if your site has a custom theme you can fix this yourself for your site by putting the html.twig file into your theme and editing it there.
Comment #4
vivek panicker commentedHi jhodgdon,
Thank you for looking into it and for giving the suggestion.
But the url query parameters have also changed. For that, the template variable generation logic also has to be changed.
I am finding it difficult to figure out the logic to do so.
It would be great if someone could help me out here.
Comment #5
jhodgdonIt would help if you could put the full URLs into the issue summary or a comment (the original and the redirect) and maybe we could figure out what is happening).
Also keep in mind that Google often puts a lot of extra stuff into its URLs that are not necessary.
Also... These URLs were originally derived from going to Google Maps, finding an address, clicking on the Embed link, and figuring out what the URL was. We can probably start over and do that again, to figure out where in the URL the language and address should go.
Comment #6
vivek panicker commentedHi jhodgdon,
I shall myself put some effort into finding out if it is possible to come up with a solution for this problem.
The following is the redirect that is happening:
Original
https://maps.google.com/maps?hl=en&q=IN%2C+West+Bengal%2C+Kolkata%2C+700071%2C+Queens+Way%2C%2C+Maidan%2C+Victoria+Memorial+Hall&t=m&z=15&output=embedRedirect
https://www.google.com/maps/embed?origin=mfe&pb=!1m4!2m1!1sIN,+West+Bengal,+Kolkata,+700071,+Queens+Way,,+Maidan,+Victoria+Memorial+Hall!5e0!6i15!3m1!1sen!5m1!1senComment #7
jhodgdonThanks! So it looks like the address part is staying the same, encoded as
IN%2C+West+Bengal%2C+Kolkata%2C+700071%2C+Queens+Way%2C%2C+Maidan%2C+Victoria+Memorial+Hall.We'd probably need to experiment with the other map parameters to figure them out. ... In the original, we have
hl=en , t=m , z=15, which are the language (en), zoom level (15), and map type (m). In the redirect, I see6i15which could be the zoom level, and 1sen which could be the language? Hard to say for sure.So my suggestion would be to put some addresses into Google Maps and click the Embed button, trying with some different zoom levels and map types, to see what the parameters would be. Check the settings for this module to see what other things we'd need to vary to cover all the settings.
Comment #8
vivek panicker commentedThanks for the help!
There are no online resources as such available from Google to help us out here. But I found some blogs which helped me to decode the URL string.
So there is some sort of hierarchy here, but the hierarchy shown in the blogs is different from the hierarchy I am able to construct for my URL string.
What I am planning to do is to keep hierarchy same as the one I have, and try to generate it dynamically.
The only change I feel I have to make apart from in the template file, is for the map type value generation. There now seems to be only 2 types of map:
Apart from this as pointed out by you,
1sendoes stand for the langcode and6i15does stand for the zoom level.I'll generate and provide the patch for it. I'll need someone to test the static map part as I am not using it.
Comment #9
vivek panicker commentedThis patch should fix the issue for dynamic map and link of larger map.
But this does not take into account static maps, as I do not have the API key.
Comment #10
vivek panicker commentedComment #11
jhodgdonThat patch is getting a "failed to apply" error...
Comment #12
vivek panicker commentedYes, I saw that too.
I have generated a fresh patch and have uploaded it.
Comment #13
vivek panicker commentedUploading this patch after fixing coding standards issue.
Comment #14
vivek panicker commentedComment #15
jhodgdonWhen you upload a patch, please just set the issue status to Needs Review, which will automatically launch the correct test. You should not need to manually add tests. Thanks!
Comment #16
jhodgdonI took a quick look at the latest patch. I actually think it would be better to leave the settings form as it is, and instead when you are sending data to the theme layer, translate the map types to fit the current Google URLs. That will make existing sites still work. The way you have done it, if someone updates the module to the new version, their existing configuration for the field formatter will no longer work. So you would need to have an update hook that would go through and update everyone's configuration, which is not in the patch.
Updating the variables sent to the theme is also a problem, because if someone is using a customized theme template file, it will no longer be getting the same data.
So... I'm setting the patch to needs work. We need a patch that will make it so that sites that already exist (with existing configuration and perhaps customized theme templates) will still work if they update to the new version. This patch will not work.
Comment #17
vivek panicker commentedHi jhodgdon,
Yes, I too realized the issue with updating the values in the settings form and the necessity for an update hook. I just wanted to share the code as fast as possible so that someone could review and it tell me if I was heading in the right direction.
So, thank you for the review and the explanation!
I did not though think about translating values when sent to the theme layer. But as you pointed out, that people with customized theme template would not be able to make use of the updated settings values.
I shall put some thought into it and see if I can come up with a solution.
Comment #18
jhodgdonI think the solution is probably to leave the configuration and the theme variables the same, and have the logic of translating the old map type to the new map type be done in the theme template. That way, old templates that are outputting the old URLs with the old values will still work, old configuration will still work (without an update hook), and the new template will still be able to output the new URL.
Comment #19
vivek panicker commentedYeah... I guess that would be good. It would help maintain compatibility.
Also the approach it has made the code much simpler.
I am uploading another patch with changes just in the template in
URL valueandmap_type value.Comment #20
vivek panicker commentedThe patch is failing for higher Drupal versions as some deprecated methods are being called.
So I tested against Drupal 8.6 and the patch works.
I guess the tests need to be updated as well.
Comment #21
jhodgdonYes, we need to fix the deprecations. See #3088320: Make sure Simple Google Maps is fully Drupal 9 compatible for that.
The patch looks like the right approach. I haven't tested it yet, and I think it needs manual testing. Thanks very much for all your work!
One question: I think when I first made this module, I experimented with taking bits out of the URL so that I had a minimal URL to work with. You might try that with the new URL. For instance, maybe it doesn't need the language code twice:
!3m1!1s{{ langcode }}!5m1!1s{{ langcode }}? I am not sure, it would require some experiments to see if it still works without some of the little bits in the URL that we don't really know what they are.Comment #22
vivek panicker commentedI have tried out a shortened URL and created a patch for it.
Uploading it now....
I don't think it can be any shorter than this.
One thing I would like to again point out that this patch or the previous one does not fix the URL for static maps as I do not have any API key to test it.
Glad to help!
Comment #23
jhodgdonThanks for that testing! But that may be too short -- it looks like that patch doesn't output the language code?
Comment #24
vivek panicker commentedThanks for pointing it out. Had removed that code in a hurry.
I have created a new patch with the langcode parameter that is required.
Comment #25
jhodgdonThat looks better! We should do a bit of manual testing with various options to verify that the field formatter settings still work for zoom, language, map type, and of course the address.
Meanwhile, you can of course put the new template into your site's theme and benefit from all of your hard work on this patch, which is much appreciated!
Comment #26
jhodgdonComment #27
vivek panicker commentedThanks for the approval :)
I have downloaded the dev version of the module in my project and applied the patch to it. Worked fine.
I have also done some testing and things look fine to me.
Hope that the it works fine for other testers as well!
Comment #28
baluertlIʼm not sure whether I understood the purpose of this module correctly, but as far as I see, Google Maps GUI now uses exclusively
&mid=(named after probably "Map ID"?) parameter is its URLs. I tried many ways but did not manage to get a URL of my map similar to these exclamation mark-separated&pb=!1m4!2m1!1s…style which weʼre compositing.Maybe Google just changed the embedding options since the last comment here and we have to accommodate with their new rules. When I require the embed code of my map I get the following markup offered:
<iframe src="https://www.google.com/maps/d/embed?mid=1GGjVwVq2A4YFsCbQ0Al1wzGBfpRRnVtG" width="640" height="480"></iframe>Such sophisticated options this field formatter was used to offer are nowhere mentioned by Google on the GUI anymore. Correct me if Iʼm wrong, maybe thereʼs another "Google Map" service in the overwhelming Alphabet-universe I just missed?
Comment #29
jhodgdonThe original embed code for this module was derived from reverse-engineering an embed generated by searching on the Google Maps web site for an address, clicking on Share, and looking at the embed code. It was not based on a published API. The no-API-key embed may fail to work in the future (or even now?) if they are publishing the embed with a map ID and keeping track of the options behind the scenes.
The URL link was also based on reverse-engineering links from the popup share button.
The static map option in this module does used a published API, and requires a Google Maps API key and payment to Google.
Comment #30
bserem commentedToday our production pages with simple_gmap stopped working and displayed a sameorigin error:
The patch in #24 solves the issue nicely and quickly.
I'd put this to RTBC since it seems that without it the module won't work properly anymore.
Comment #31
designate commentedWhat would be the #24 patch for Drupal 7 version of this module?
Comment #32
darrell_ulm commentedAdding support, agree that the patch in #24 applied works and solves the issue.
Comment #33
cbwiedel commentedConfirming patch in #24 solved my issue too
Comment #34
hunterbuchanan commentedAgreed, just tested patch #24, it solves the problem for us as well.
This URL issue used to just be a minor annoyance, but now that Google has made changes on their end, the module is entirely broken without this fix. Making adjustments to the issue to reflect the urgency here.
Patch #24 should be committed to dev right away, and a new release including this change should be tagged. It looks like the current dev branch is 8.x-1.x, while the release versions are up to 3.0.0, but I'm not sure if that has to change in order to move this forward.
Comment #35
Anonymous (not verified) commentedWe tested the patch on a site using Drupal 9 and it fixes the broken maps for the embedded dynamic map.
Waiting for a dev or release version before we update all our sites.
Comment #36
cboyden commentedHere's a patch for the 7.x version based on #24.
Comment #37
cboyden commentedComment #38
designate commentedConfirmation that patch for Drupal 7 as described in # 36 works and solves the problem!
Comment #39
jhodgdonHi there! Thanks everyone for reviewing these patches.
I'm sorry but I'm not able to make the commit/release for about a week (away from office). Possibly the module co-maintainer for Drupal 8+ can take care of it before that.
Comment #40
hunterbuchanan commentedThanks for letting us know @jhodgdon! I messaged Martin directly to ask him if he could take care of it soon.
Comment #43
jhodgdonThanks everyone who participated in this issue by creating and testing patches, as well as discussing the issue and how to fix it! And thanks for your patience. There are now a new 8.x/9.x and 7.x releases available on the project page, with this fix included.
Comment #44
jhodgdon