Solved MS Access - Google Maps API, On_Click get Cords

ironfelix717

Registered User.
Local time
Today, 15:19
Joined
Sep 20, 2019
Messages
193
Hi all,

Last night i fiddled around and after about 3 hours of fiddling around, some black magic happened and i was able to embed Google Maps into a form.

Here is the source i followed: CLICK

This code uses the ActiveX control: Microsoft Web Browser control, which for whatever reason appears to be the preferred choice for displaying maps. The code is able to do 2 things:

1.) Point the Maps to user entered lat/long cords (from textbox)
2.) Retrieve lat/long cords from Maps FROM ADDRESS types into Maps API search bar

What i would like to do is retrieve the coordinates from the control On_Click. Fortunately, the Maps API shows you the cordinates in the bottom of the window when you select an area, but you can't copy the coordinates or anything so it kinda defeats the purpose. I don't have a clue how this code works (how does XML have anything to do with google maps). Someone smarter than me, i hope can chime in and try and get this code to pull the coordinates to VBA when clicked.

P.S. will post example file if needed for solving.
 
Hi. Yes, I think a sample file will help speed things up. Please post it, if you can. Thanks.
 
@theDBguy
I have attached a sample. All you would need is an API Key which can be obtain in under 5 minutes for free from this link:
HERE

Let me know what you think!

@Gasman
Good info, i didn't see that example. The key i have is for embedded use only. His example requires a 3 service key that appears by quick glance that you need to setup a billing account with Google's Cloud API. This is a personal project with light duty on this feature, but I would prefer to try and get my example working - but i suspect its not feasible. I'll see what the Pro's say. If not, i'll investigate Colin's work further.

Thanks
 

Attachments

Although Google changed their rules so that you now have to supply credit card details to use their mapping APIs, you then get a free usage limit. You are very unlikely to trigger payments if this is for personal use. From memory you get around 22000 'free' static map searches per month with similar numbers for other API search types.

Use an image control if you only want to download and embed a static map. This is faster and also is free of all the Google advertising 'junk ' that you get on a dynamic map. If you do want to embed a live dynamic map then you would need a Web browser control.

For info, you can find several other mapping examples on my website, both free and commercial.
These include addresses from postcodes, getting maps based on EXIF data in photos, adding markers (pushpins) to maps to display nearby places, route planning etc.
You may find some useful ideas you can include in your example

EDIT:
1. The API keys needed for my various examples are exactly the same as those obtained from the link you supplied.
I've no idea what you mean by a 3 service key unless you're referring to the number of APIs that my example app uses.
When you obtain an API key you can use it with as many Google APIs as you wish. Just activate the ones relevant to your project.
From memory, one of my commercial projects makes use of the following 12 APIs on the same API Key
1589114117150.png


2. Suggest you read the very extensive guides produced by Google for using their various mapping related APIs.
 
Last edited:
@isladogs:

I'll probably just stick with my "free" method and not have to worry that Google is billing me unknowingly (not that I would realistically meet the quota). The only caveat is not being able to return GPS cords from the map marker, while still being able to point the map to specific coordinates.

Should i need to grab GPS cords from the marker, that would require enabling billing and activating the API service i need (embedded Maps + geocoding, geolocating). For now, I am able to copy the cords from the browser control, which will fit my needs.

By 3 service key, i was explaining that your method requires 3 API services enabled on that key. Which is consistent with your words, hence the reason you're on a billing account (geolocating, geocoding aren't free).

You will need to enable THREE map APIs: Static Maps / Javascript Maps / Geocoding
 
Fair enough ... though its highly unlikely you would be billed unexpectedly.
The charges are I believe aimed at large organisations

For info, I've only been charged once since the new charging policy was introduced a couple of years ago.
I knew in advance that a large search involving over 100,000 geolocation searches would be chargeable.
I was trying to sort out something whilst developing a commercial app so decided to proceed.
I calculated the likely cost in advance and the bill was approximately what I anticipated. IIRC about £12 GBP.
 

Users who are viewing this thread

Back
Top Bottom