astuder / lightroom-map-fix

Fixing the Map module in Lightroom Classic

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Switch Map Renderung to OSM?

limex opened this issue · comments

Hi,
is there any chance to use OSM (Openstreetmap) for maps rendering?
Reason: The google map - even the terrain map - doesn't show smaller tracks and other outdoor sport related features.

I found some code in locationmapview.lua but I am struggling to find out what and where code changes could be applied.

Thanks in advance.

I think supporting OSM would require a complete rewrite of the Locations module. Unless there is some kind of shim for OSM that exposes an API compatible with Google Maps.

commented

I think it would be relatively easy. No need to replace the whole API, because you can add an OpenStreetMap layer to Google Maps.

In the Lua code, find the command that initializes the "light" and "dark" maps:

var lightMapType = new google.maps.StyledMapType( lightStyle, styledMapOptions );

And replace this with code to add an OSM layer:

var lightMapType = new google.maps.ImageMapType({ getTileUrl: ... });

Even better, since the whole map initialization is included in the Lua code, you could add a Map Type Control to the map, which would let you choose from many map layers that you could add yourself.

I have not tested any of this (yet, I would like to), but I've done something like this a couple of years ago with GeoSetter, adding no less than 10 custom maps, among others Bing, ArcGIS, ESRI and several OSM-based map layers to the build-in Google map.

Thanks for the pointers. Please keep us posted if you get it working. Happy to incorporate additional functionality in my Python script as required.

commented

Wohooooo! 😲

Clipboard Image (1)

After patching the API key, execute the following line:

patchluastr.py LOCATIONMAPVIEW.bin "StyledMapType( lightStyle, styledMapOptions )" "ImageMapType({ getTileUrl: function(coord, zoom) { var tilesPerGlobe = 1 << zoom; var x = coord.x % tilesPerGlobe; if (x < 0) { x = tilesPerGlobe+x; } return 'https://tile.openstreetmap.org/' + zoom + '/' + x + '/' + coord.y + '.png'; }, tileSize: new google.maps.Size(256, 256), name: 'OpenStreetMap', maxZoom: 19 })" -o LOCATIONMAPVIEW-osm.bin

Now use LOCATIONMAPVIEW-osm.bin with Resource Hacker instead of LOCATIONMAPVIEW.bin, and afterwards OpenStreetMap is available as the "Light" map style.

commented

For anybody who wants to tinker with the map window, this is also a very convenient hack:

patchluastr.py LOCATIONMAPVIEW.bin "width:100%; height:100%" "width:100%; height:50%" -o LOCATIONMAPVIEW-50p.bin
patchluastr.py LOCATIONMAPVIEW-50p.bin "background: #3f3f3f;" "background: #3f3f3f; color: white;" -o LOCATIONMAPVIEW-color.bin
patchluastr.py LOCATIONMAPVIEW-color.bin "</div>" "</div><ul id='myULContainer'></ul><script src='https://cdn.rawgit.com/Alorel/console-log-html/master/console-log-html.min.js'></script><script>ConsoleLogHTML.connect(document.getElementById('myULContainer'));</script>" -o LOCATIONMAPVIEW-con.bin
  1. Reduce the map window size.
  2. Make text output readable.
  3. Install a script to redirect console output to the window

And enjoy actually readable error messages!

Clipboard Image (3)

Added your hacks to a new section in the README. Thanks!
https://github.com/astuder/lightroom-map-fix/blob/master/README.md#more-hacks

@pbb72 : Thanks sooo much.