astuder / lightroom-map-fix

Fixing the Map module in Lightroom Classic
125 stars 17 forks source link

Address Lookup doesn't work with fix? #3

Closed evanwarner closed 4 years ago

evanwarner commented 5 years ago

Everything seems to be working with this fix except Address Lookup. None of my images are receiving the gray suggested IPTC locations, and the Address Lookup indicator is stuck at "Looking up N locations." My Google Cloud console is showing about 30% of the Geocoding API requests are triggering 403 errors (which may or may not be related since it's not 100% errors).

I poked around a few of the other .lua files but didn't see any other API calls to update.

Anyone else experiencing this?

astuder commented 5 years ago

You may run in to the 50 requests / second limit described here: https://developers.google.com/maps/documentation/geocoding/usage-and-billing Are you trying to do bulk operations? In my own use, I only do manual geo-tagging.

evanwarner commented 5 years ago

Not that much bulk. I import tracklogs from photoshoots then autotag photos on that. The one I ran after this fix had ~40 photos in it. I don't think I'm hitting the 50/s limit as the cloud console is showing < 20 hits from this last attempt (but it was 100% 403 errors).

astuder commented 5 years ago

Does the map show you a place name at the top right? I think that would use same API.

I think the troublesome API is: https://developers.google.com/maps/documentation/geocoding/start#reverse

On the Usage and Billing page, they mention "keyless access" which was deprecated. I wonder if there are some of these calls in the Lightroom module. Though not sure how that would still show up in your Cloud Console. https://developers.google.com/maps/documentation/geocoding/usage-and-billing

If there's a string starting with "https://maps.googleapis.com/maps/api/geocode/json?" but no key, you could try to patch that by inserting your key as URL parameter.

evanwarner commented 5 years ago

Yep, the location at upper right displays correctly and changes as I pan around the map. Console shows a spike in successful geocoding hits after I do that.

I'm beginning to think this is not an API error and that Lightroom is for some reason not even triggering the lookup.

astuder commented 5 years ago

Warning: I haven't tried this myself.

The files LOCATIONMAPVIEW.LUA and REVERSEGEOCODESERVICEFALLBACK.LUA make heavy use of the JavaScript APIs. As part of that, they include HTML code that loads JavaScript libraries from Google. The documentation by Google says to include the API key when loading these libraries. https://developers.google.com/maps/documentation/javascript/get-api-key

So, you could try to replace this string: http://maps.google.com/maps/api/js?sensor=false with https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&sensor=false

Definitely make a backup of your Location.lrmodule before trying that.

evanwarner commented 5 years ago

Ok, I think I found the culprit. By examining (using Charles) the network call made by Lightroom when I drop a photo onto the map, I found this error: Unable to authenticate the request. The 'signature' parameter is not required. Learn more: https://developers.google.com/maps/documentation/business/webservices/auth

The full API call URI was: /maps/api/geocode/json?key=[my-key]&language=EN&channel=lightroom-6.14&latlng=[coordinates-of-my-photo]&signature=[string-of-characters]

If I recompose that request in Charles and remove the signature parameter, I get a successful JSON response.

However, I cannot figure out where in the code that parameter is being attached. I ran a search on every file inside Lightroom.app and couldn't find the signature value. I couldn't even find an instance of the word "signature" in the Location.agmodule package. Perhaps it's obfuscated somewhere else?

Update: After some additional tinkering I can say that the call is originating from AgReverseGeocodeService.lua (removing and re-adding the obsolete sensor=false parameter in there causes the failing call in Charles to also reflect that change.)

astuder commented 5 years ago

Just came here to say, that it's most likely the URL in AgReverseGeocodeService.lua.

I see the format string for "latlang" %s&latlng=%f,%f The %s at the beginning will be replaced with the URL string that we patched.

But I can't find "signature" in any of the files. Probably obfuscated for security reasons, or might be calculated from the LR license key. ok, I should read your full post before thinking :-)

There's sig, followed by nature, = and & in LocationDebugPanel.lua. You could try to see whether the signature variable name changes by replacing nature with something else. If yes, and we're lucky, Google may simply ignore the unknown variable name.

evanwarner commented 5 years ago

@astuder BRAVO!!! That indeed is the spot. I used your Python script to change nature to something else. Charles reflects that change in the URI and Lightroom's address lookup is instantly up and running again.

rs38 commented 5 years ago

where can I see the javascript console that LR mentions in the error message for debugging???

astuder commented 5 years ago

@rs38 I wondered as well when I started looking into how to fix the maps, but I haven't figured out how to get to the javascript consolte.

tkopley commented 4 years ago

Many thanks astuder for a nice fix. I just tried the Map module in Lightroom 6.14 for the first time in well over a year, got the surprising (for me) map load error, found a Lightroom users forum on the topic with a link to your repository, and easily got it working again following your instructions (and setting up all the Google Cloud prerequisites). This is on a Mac running 10.14.6 (Mojave). I am not an IT professional, so I'm happy it all worked out. If anything goes wrong, I'll be sure to check out some of the other issues people have brought up here. Great resource for sure. Thanks again astuder and everyone for their contributions.