Centre Google Maps view on cursor

I often take screenshots of Google Maps, with the place of interest (e.g., a city) being x pixels from the bottom of the screen and y pixels from the right of the screen. I currently position the screen manually before taking screenshots, which is a bit of a faff. Is there any way you could automate the positioning using Keyboard Maestro? E.g., you hover your mouse over the place of interest, then press a hotkey, and the place of interest is centred.

This solution is adapted from Peter's macro in Mouse drag
and using a dummy offset to ensure drag will work.

This assume running Google map site in Firefox/Chrome, Meta+M keys will move the map under mouse to window centre.

[FFX] Google Map: Center Mouse's Location.kmmacros (9.5 KB)

Brilliant, thanks!

The centring is not exactly where I want it to be; which variables should I adjust to change the horizontal and vertical alignment?

"I often take screenshots of Google Maps, with the place of interest (e.g., a city) being x pixels from the bottom of the screen and y pixels from the right of the screen. ....

you hover your mouse over the place of interest, then press a hotkey, and the place of interest is centred." ?

My understanding is that window's centre is how normally desired map should be positioned but you could mean some other way. Could you explain further on what you mean ?

Apologies – "centred" was a bad choice of word. I do not want the place of interest to be precisely centred relative to the window; I would like to define how many pixels from the top/bottom and left/right of the window it is. This is because the screenshot I take is not of the entire window – I cut out the Google Maps controls and whatnot.

"I would like to define how many pixels from the top/bottom and left/right of the window it is. "

From what I deduce is that you want to define a set of four window padding value (left, right, top, bottom) which can be defined in a dialog box, and then by pressing a shortcut key you can use a Screenshot Action (from keyboard maestro) to create a screenshot into clipboard . Is that correct ?

I'll describe my current manual process to see if that helps me better express the solution I'm looking for!

Say I want to take a screenshot of London in Google Maps. I would like London to be centred in the screen relative to the screenshot I take, which isn't of the entire window. Here's what I do:

  1. Enter "London" in the search bar, to make London appear onscreen.
  2. Clear the search and minimise the search bar to maximise the part of the screen in which the map appears.
  3. Click and drag the screen so that (a) the "nd" in "London" is vertically in line with the "e" of the Google logo at the bottom of the screen, and (b) "London" is ~355px above the "Google" logo. (This will ensure that in the screenshot I take, "London" is centred relative to the screenshot.)
  4. Take a screenshot not of the entire screen, but just the part so that you don't see any of the navigation buttons.

Here are screenshots showing each of the four steps above:




I'm looking for a solution that automates step three.

I hope that clarifies things!

This is the macro that should do what you describe.

The yellow group is where you need to adjust the variable value for left, right, top bottom of window. the google label is centred so you need the respective variable slightly.

[FFX] Google Map: Screen Capture.kmmacros (15.4 KB)

2 Likes

This works perfectly and is a big timesaver. Thank you very much!