The Show Location in Maps action in Automator takes a Photos Media Item as input, not a Finder item.
In other words, it could be used in conjunction with a Get Selected Photos Item action, but not as the first action in a Automator Service/Quick Action that is set as Workflow receives current [image files] in [Finder].
Have look at: The “Show Location in Maps” Action
Update to address comment:
Is there any other way I can retrieve the map location and then show it in the Map app?
Here is one way to accomplish the goal...
The following example AppleScript code was tested in a Run AppleScript action in an Automator Service/Quick Action under macOS Catalina and worked for me without any issues:
on run {input, parameters}
set imageFile to the quoted form of ¬
the POSIX path of (the first item of input)
set shellCMD to {"mdls -name kMDItemLatitude -name kMDItemLongitude ", ¬
imageFile, " | awk '{print $NF}'"} as string
set LatLon to paragraphs of (do shell script shellCMD)
if (LatLon as string) contains "null" then return
set latitude to first item of LatLon
set longitude to second item of LatLon
set mapsLocation to {"https://maps.apple.com/?ll=", ¬
latitude, ",", longitude} as string
open location mapsLocation
tell application "Maps" to activate
delay 0.5
tell application "System Events" to ¬
keystroke "D" using {shift down, command down}
end run
Notes:
- As currently coded it only works with one selected image file in Finder. Additional coding is required if want to act on multiple selected image files in Finder.
- As currently coded, if a selected image file in Finder does not contain meta data for
kMDItemLatitude
and kMDItemLongitude
for mdls
to output, then the script stops without any feedback. If you what to be notified, then additional coding is required.
Note: The example AppleScript code is just that and sans any included error handling does not contain any additional error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors. Additionally, the use of the delay command may be necessary between events where appropriate, e.g. delay 0.5
, with the value of the delay set appropriately.