Search address on Google Maps

Hi there,

How would you program a task where

  1. you manually highlight an address like "123 ABC Street, Kansas City, MO"
  2. KM takes the address and pastes it into Google Maps
  3. KM copies the link to the Google Map search results for that address to named variable "Map Result"

Thank you!
Josie

Hi Josie,

Give this a shot:
Build URL- Google Maps search.kmmacros (2.3 KB)

Macro Image

This skips your second step (in the name of avoiding UI manipulation whenever possible), but hopefully it still gets you the end result you were looking for.

Cheers,
Vito

Hi Vito!

Thanks for this!! I just tried it and nothing happened. I added a pause between each step and still nothing.

I don't know if it makes a difference but I'm using KM Link on the Stream Deck to execute it.

What do you think?

Thanks!
Josie


w

Try changing /search to /place/ in the last step—that's what the URL shows for me after looking up an address.

-rob.

Hi Rob!

Thanks for sending this. I tried it as well and still nothing is happening.

It seems like it isn't even copying the address. Do you have any other suggestions?

If nothing is happening, I would check out the Debugger to make sure the macro is being triggered.

You could also add a Display Text action to get a look at the Map Result variable.

Yep, that's what I'd suggest: use a Display Text action to see the value of the variable before the prepend.

-rob.

I had some time, so I played around with this a bit this morning. URL encoded addresses do not seem to work with Google Maps. Instead, I had to process the copied address to do three things:

  1. Replace any line breaks with plus signs
  2. Replace any spaces with plus signs
  3. Replace any dots with commas

Doing that, it seems to work. This macro assumes you have the address highlighted, then presses Command-C to put it on the clipboard. It then does the above replacements, sets the final URL, and finally opens that URL.

google maps.kmmacros (4.8 KB)

It seems to work here, but please let me know how it works for you. (Note that my macro creates some variables that aren't strictly necessary, but I find it easier for others to see what's happening. They're also local variables, so they'll vanish when the macro finishes.)

-rob.

Not sure what happened here, but I tested the percent-encoded output from my macro and it worked in Safari, Chrome, and Firefox.
Perhaps I didn't test a large enough variety of inputs?

Nevertheless, whether you use percent-encoding or convert everything to plus signs, I would still recommend /search/ over /place/.

If I have anything short of a full address (e.g., "123 Main St" without city/state/zip), /place/ seems to fail outright (for me, at least), while /search/ uses the location context from my IP address to provide a best guess (as you would expect from a search within the app).

If I have a specific and complete mailing address, both /search/ and /place/ produce the same result.

Not sure either, but when I sent a multi-line encoded address through the URL encode filter, Google Maps failed (using either /place or /search). I just used my home address (in USA) as the test. Weird.

Good to know. I hardly ever look up incomplete addresses, so the shortcut I have in my web search macro is the /place/ one, but sounds like I should switch it.

-rob.

Thank you both!! I appreciate the "getting to the bottom of this" efforts :blush:

I'm still working on the debugging. I will update you when I am hopefully able to get this to execute!

Josie