I have an HTML file that generates a Map, and I display it inside a WindowsForms application when opening a screen. From one day to the next it stopped working.
I use a Web Browser component.
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Complex icons</title>
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
var markers = [ {
'title': 'Antracnose',
'lat': '37.4220936',
'lng': '-122.083922',
'description': 'Antracnose - Fase: Ovo <br/>Medição: 4.000000'} ];
function LoadMap() {
var mapOptions = {
center: new google.maps.LatLng(markers[0].lat, markers[0].lng),
streetViewControl: false,
mapTypeId: google.maps.MapTypeId.SATELLITE
};
var infoWindow = new google.maps.InfoWindow();
var map = new google.maps.Map(document.getElementById("map"), mapOptions);
//Create LatLngBounds object.
var latlngbounds = new google.maps.LatLngBounds();
for (var i = 0; i < markers.length; i++) {
var data = markers[i]
var myLatlng = new google.maps.LatLng(data.lat, data.lng);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: data.title
});
(function (marker, data) {
google.maps.event.addListener(marker, "click", function (e) {
infoWindow.setContent("<div style = 'width:200px;min-height:40px'>" + data.description + "</div>");
infoWindow.open(map, marker);
});
})(marker, data);
//Extend each marker's position in LatLngBounds object.
latlngbounds.extend(marker.position);
}
//Get the boundaries of the Map.
var bounds = new google.maps.LatLngBounds();
//Center map and adjust Zoom based on the position of all markers.
map.setCenter(latlngbounds.getCenter());
map.fitBounds(latlngbounds);
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB9Got42VTh1NwKDSI-GBduOqTvwkKRDS4&v=quarterly&callback=LoadMap">
</script>
</body>
</html>
Today I use it to generate a temporary HTML file and read this file with the webBrowser.
I tried a few ways to create a map in an API that returned only an address with the generated map to display in the webBrowser, but it didn’t work.
On other occasions, the map stopped being displayed, and after searching a lot, the solution was to change the version of JavaScript in the map, but this time it didn’t work anymore.