First Published 5 Dec 2022 Difficulty level : Moderate
Section Links (this page):
Create a Map
Adding Map Layers
Managing the URL Character Limit
Encoding the Coordinates
Sampling the Data
This is the second in a series of articles about annotating downloaded maps in Access
The first part of this article demonstrated several of the different ways that online maps can be modified by adding additional layers.
Maps can be obtained from various online sources including Google, Bing, Open Street Maps & Michelin. This article focuses on using Google Maps
The generated map can be displayed using a web browser control (standard or ActiveX) or as a downloaded image.
1. Create a Map Return To Top
To create a map centred on a specified location, the location can be based on any of the following:
• Zip code / Postcode e.g. SE1 7PB
• Co-ordinates e.g. 51.5027667,-0.1215859 (lat/long)
• Full/partial address e.g. London Eye ; 6 Hill Street, Clevedon, Somerset
You must also specify:
• Map size in pixels e.g. 640x400 ; 480x320
• Zoom value in the range 1-20 where 1 = whole Earth and 20 = rooftop level
• Map type (roadmap/terrain/satellite/hybrid)
• Your Google Maps API key (or equivalent for other online maps such as Bing)
This information is combined to create the Google Static Maps URL needed to generate the map:
For example, this URL (153 characters including the API key) creates the map shown below:
2. Adding Map Layers Return To Top
Once you have generated standard Google static maps, the next step is to personalise the map for clients
To do this, one or more additional items (map layers) can optionally be added including the use of:
• Marker points e.g. to mark client locations or nearby places
• Lines joining 2 or more points e.g. to indicate routes between locations
• Circles around a location e.g. to show places of a specified type within a specified distance
• Boundary shapes e.g. to show postcode or regional boundaries
• Feature styles e.g. show local & main roads in selected colours or other points of interest
• Scale (1 or 2) - only affects the photographs used in maps - for satellite / hybrid maps only.
Using scale = 2 allows you to zoom in on a map area (using a browser control) or improve the map quality (downloaded image)
All annotations are added as additional map layers using code as part of the URL used to generate the map.
Several layers can be combined to include additional information.
For example, the next image shows the same location as a roadmap with these map layers added:
• red marker labelled X centred on the specified postcode
• horizontal & vertical blue lines intersecting at the same location
• main roads marked in blue and minor roads in grey
• parks labelled & shaded in green
The URL required to create this map is of course significantly longer (656 characters including the API key):
Each additional feature added to the map increases the URL length.
Eventually you will hit the 2083-character URL limit using the current web browser control which is still based on the antiquated Internet Explorer 7 browser.
a) The limit is 2048 characters for the standard web browser control or 2083 using the ActiveX web browser
b) It is possible to overcome some issues with the old web browser control by using browser emulation either as IE11 or Edge mode.
This requires editing the registry. However, this is both simple and safe to do.
For full details, see my article: Fix Google maps display issues in Access web browser control
c) A new web browser control based on the Chromium Edge browser is currently under development and this is likely to have a much larger URL character limit.
Hopefully, the new Edge browser control should be released by March 2023.
d) However, the maximum URL length will still be limited by the maximum length determined by Google.
From widespread testing, this currently appears to be 16,384 (16K) characters i.e. about 8 times larger than using an IE based web browser control
Using a downloaded static map image bypasses the restrictions of the IE web browser control but the URL length still subject to the limits set by Google.
3. Managing the URL Character Limit Return To Top
Adding certain features such as complex boundary lines would in some cases cause the character limit to be surpassed many times over.
However, there are ways of overcoming these issues.
There are two main processes used to manage the total number of characters in the URL:
a) Encoding the co-ordinates
b) Sampling the data
4. Encoding the co-ordinates Return To Top
Encoding uses complex algorithms to significantly shorten URLs without losing accuracy
In several of my mapping applications such as the UK Postal Address Finder app, encoded data is used to add shapes such as circles and octagons to the maps.
It is also extensively used to show boundary lines e.g. postcode areas or county bouundaries
For example, the boundary coordinates for two postcode areas are shown below together with the encoded versions of the same data
Encoding ALL the boundary co-ordinate data has reduced the total characters used in the URL by about one third e.g. from 1558 to 1080 characters
Encoding is also used to draw circles around a specified location.
For example, when showing nearby places of interest within a set radius.
The 'circle' is actually made up of 36 straight lines drawn by joining 36 points at 10 degree intervals all of which are equidistant from the central location
However, it looks like a perfect circle to the end user!
5. Sampling the data Return To Top
Sampling boundary path data is necessary where the total character length is much longer such that the URL limit would be exceeded.
With an appropriate level of sampling, the boundary can then be displayed because fewer data points are being used.
For example, the data below is for all the boundary paths for the postcode sector ZE2 9. This comprises 35 separate parts on several small islands
Combining all boundary path data, the total path length for postcode sector ZE2 9 after encoding & sampling has been reduced from 84965 to 1272 characters
The inevitable trade-off of sampling data is a reduction in accuracy.
The amount of sampling done depends on the total path length, so reduced accuracy may not be noticeable in all cases.
For example, the boundary path for postcode sector YO31 8 is well defined
Both the encoding and sampling processes are described in detail (with all required code) in my article: Encoded Map Path Co-ordinates
These processes all use additional trigonometric functions not built into Access. For full details (and code), see my article: Missing Trigonometric Functions
6. Related items / example apps Return To Top
The following apps use various geolocation features to generate maps. All are available elsewhere on this website:
a) Get Geolocation from Photos (FREE)
b) Get Current Geolocation (FREE)
c) UK Postcode Address Lookup (FREE)
d) UK Postal Address Finder (PAID)
7. Related articles / code Return To Top
a) Encoded Map Path Co-ordinates
b) Missing Trigonometric Functions
8. Useful links Return To Top
The following links will also help you get started on creating your own maps in Access:
a) Google Static Maps API Developers Guides
b) Google Nearby Places API Developers Guide
c) IE browser URL character limit
Maximum URL length is 2,083 characters in Internet Explorer (microsoft.com)
What is the maximum length of a URL in different browsers? - Stack Overflow
How long of a URL can Internet Explorer 9 take? - Stack Overflow
d) Fix Google maps display issues in Access web browser control
9. Summary Return To Top
The above article was the second in a series of articles for this website and was used to explain some of the processes involved in creating complex maps including encoding and sampling data
The third article in this series will be used to put all of this information together including showing how the URLs can be built up in code.
An example app will also be supplied with the next article
10. Feedback Return To Top
Please use the contact form below to let me know whether you found this article useful or if you have any questions.
Please also consider making a donation towards the costs of maintaining this website. Thank you
Colin Riddington Mendip Data Systems Last Updated 5 Dec 2022
Return to Access Articles Page 2 of 3 1 2 3 Return To Top