Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening Google Maps gives Script error in Access web browser control (OSM no problem)

Status
Not open for further replies.

PeDa

Technical User
Oct 10, 2002
227
NL
My Microsoft Access form contains a web browser control that is populated by:
Code:
If Forms!frmPhotos!radOSM Then
  Forms!frmPhotos!WebBrowser.Navigate "localhost/LocatorO.php?lat=" & Me!fLatitude & "&lon=" & Me!fLongitude
Else
  Forms!frmPhotos!WebBrowser.Navigate "localhost/LocatorG.php?lat=" & Me!fLatitude & "&lon=" & Me!fLongitude
End If
If radOSM is True then an OpenStreetMap is loaded, otherwise a Google map.

Both the OpenStreetMap and the Google map work fine if I load the URL directly into the browser:
Code:
localhost/LocatorG.php?lat=52.354473&lon=4.895552
localhost/LocatorO.php?lat=52.354473&lon=4.895552
The OSM version also works fine in my Access form, but the Google Maps version gives a script error at Line 0, character 0 and the URL of Google Maps API src:
Code:
<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
    <title>Locator</title>
    <style>#map {height:350px;width:350px;}</style>
    <style type='text/css'>#map {height:300px;width:300px;}</style>
    [highlight #73D216]<script src='[URL unfurl="true"]https://maps.googleapis.com/maps/api/js?key=[/URL][MyKey]'></script>[/highlight]
    <script type='text/javascript' src='misc/StyledMarker.js'></script>
    <script src='[URL unfurl="true"]https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>[/URL]
  </head>
  <body id=body onload='initMap()'>
    <div id="map"></div>
    <script>
      var myLatLng = {lat: 52.354473, lng: 4.895552};
      function initMap() {
        var mapCanvas = document.getElementById('map');
        var mapOptions = {center:myLatLng,zoom:18,mapTypeId:google.maps.MapTypeId.ROADMAP,streetViewControl:false,mapTypeControl:false,scaleControl:false,zoomControl:false,fullscreenControl:false};
        var map = new google.maps.Map(mapCanvas,mapOptions);
        var marker = new StyledMarker({styleIcon:new StyledIcon(StyledIconTypes.MARKER,{color:'00ff00',text:'*'}),position:myLatLng,map:map});
        myLatLng = new google.maps.LatLng(52.354355,4.895760);
        marker = new StyledMarker({styleIcon:new StyledIcon(StyledIconTypes.MARKER,{color:'ff0000'}),position:myLatLng,map:map});
        myLatLng = new google.maps.LatLng(52.354355,4.895760);
        marker = new StyledMarker({styleIcon:new StyledIcon(StyledIconTypes.MARKER,{color:'ff0000'}),position:myLatLng,map:map});
        ........(more markers added from php)
      } 
    </script>
  </body>
</html>
 
I have now found the answer to my question over on StackOverflow. The basic problem is that, by default, Microsoft Access uses Internet Explorer 7 in de browser control, and Google Maps no longer supports that version. Access must be forced to use IE 11; that can be done by adding a couple of references to the Windows 10 Registry, for example via a batch file containing:
Code:
reg add "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION" /v MSACCESS.EXE /t REG_DWORD /d 11000
reg add "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_DOCUMENT_COMPATIBLE_MODE" /v MSACCESS.EXE /t REG_DWORD /d 11000
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top