How to connect to Google Maps GUI and draw a circle

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
r2997790
Posts: 71
Joined: 02 Feb 2017, 02:46

How to connect to Google Maps GUI and draw a circle

28 Oct 2022, 07:47

Hi everyone,

I have a project where I need to append circles to a google map. I've been using the Google Maps API with success to retrieve data BUT to control the map from within a AHK GUI to overlay a circle based on coordinates is proving beyond me.

I've found this example of what I want to do: https://developers.google.com/maps/documentation/javascript/examples/circle-simple
And this reference too: https://www.w3schools.com/graphics/google_maps_basic.asp

But basically I can't figure out how to convert the function from Javascript to AHK and call it.

Code: Select all

function myMap() {
var mapProp= {
  center:new google.maps.LatLng(51.508742,-0.120850),
  zoom:5,
};
var map = new google.maps.Map(document.getElementById("googleMap"),mapProp);
}
This is my ahk code:

Code: Select all

Gui Add, ActiveX, vWB xp yp+50 w1200 h700, Shell.Explorer
WB.Navigate("https://maps.googleapis.com/maps/api/js?key=MYAPIKEYISHERE&callback=initMap&v=weekly") ; simply navigate to web page make it as fit as possible to gui

initMap() 
{
	
	map = new google.maps.Map(wb.document.getElementById("map"),mapTypeId: "SATELLITE")
	
	;zoom: 4,
	;center: { lat: 37.09, lng: -95.712 },
	;mapTypeId: "terrain",
}

Does anyone have any tips or suggests on how to achieve this? I sense I'm close but the answer is still evading me. :headwall: Thank you everyone!

Many thanks
R
r2997790
Posts: 71
Joined: 02 Feb 2017, 02:46

Re: How to connect to Google Maps GUI and draw a circle

28 Oct 2022, 12:10

Thank you Maclev. I looks like in ahk 1.3x you can call Javascript functions using this webview2? Do I have that right? I was trying to find an example of how I'd adapt the code above and apply the webview2 approach.

Thank you for sharing this.
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: How to connect to Google Maps GUI and draw a circle

28 Oct 2022, 12:16

webview2 is needed to display generated html in gui.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], kaka2, SmithyZoomZoom and 147 guests