Skip to content
This repository has been archived by the owner on Nov 9, 2023. It is now read-only.

Google Maps API does not work on IE. Window.onload event does not trigger as there is some error with Google API when used on IE browser but works well with other browser. #582

Open
VINOD1ST opened this issue Feb 14, 2019 · 0 comments

Comments

@VINOD1ST
Copy link

//This is a Hybrid Map. Map works fine on all browsers except Internet explorer (Loads a blank page)
//Window.onload does not seem to get triggered on IE.

<title>Geocoding service</title> <style> #map { height: 100%; }

/* Optional: Makes the sample page fill the window. */

html,
body {
height: 100%;
margin: 0;
padding: 0;
}

#floating-panel {
position: absolute;
top: 10px;
left: 25%;
z-index: 5;
background-color: #fff;
padding: 5px;
border: 1px solid #999;
text-align: center;
font-family: 'Roboto', 'sans-serif';
line-height: 30px;
padding-left: 10px;
}
</style>

<script> function initMap() { var map = new google.maps.Map(document.getElementById('map'), { zoom: 20, mapTypeId:google.maps.MapTypeId.HYBRID }); var geocoder = new google.maps.Geocoder(); window.onload = function (){document.getElementById('submit').click();} document.getElementById('submit').addEventListener('click', function() { geocodeAddress(geocoder, map); }); } function geocodeAddress(geocoder, resultsMap) { var address = document.getElementById('address').value; geocoder.geocode({ 'address': address }, function(results, status) { if (status === 'OK') { resultsMap.setCenter(results[0].geometry.location); var marker = new google.maps.Marker({ map: resultsMap, position: results[0].geometry.location }); } else { alert('Geocode was not successful for the following reason: ' + status); } }); } </script> <script async defer src="https://maps.googleapis.com/maps/api/js?key=YOUR_KEY&callback=initMap"> </script>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant