M
M
Max2015-05-18 22:00:00
Google
Max, 2015-05-18 22:00:00

Why are Google Maps not displaying correctly?

Hello, please tell me why there can be such a gray background on the Google map? 457a8fd10f60421bae50ad988fea2de4.PNG
Block where the map is displayed:

<div id="map_canvas" style="width: 800px; height: 100%;"></div>

And the script:
function initialize_map( ) {
     var latlng = new google.maps.LatLng(49.25100320801442,28.541126489672024);
     var myOptions = {
     zoom: 18,
     center: latlng,
     mapTypeId: google.maps.MapTypeId.ROADMAP
     };
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    var polygonCoords = [
   	  new google.maps.LatLng(49.25156346163994,28.542151093515713),
   	  new google.maps.LatLng(49.25113626882619,28.542376399072964),
   	  new google.maps.LatLng(49.25074759018555,28.541657567056973),
   	  new google.maps.LatLng(49.25076509829823,28.54119622710641),
   	  new google.maps.LatLng(49.25100320801442,28.541126489672024)
   	 ];
   	 var polygon = new google.maps.Polygon({
   	  path: polygonCoords,
   	  strokeColor: "#5196DB",
   	  strokeOpacity: 1,
   	  strokeWeight: 2,
   	  fillColor: "#8ab9e7",
   	  fillOpacity: 0.5
   	 });
   	 polygon.setMap(map);   
   	 return map;
   }

Card Styles:
#modal_form {
  	width: 800px;
  	height: 800px;
  	background: #fff;
  	position: absolute;
  	z-index: 5;
  	padding: 0px 0px;
  	padding-top:45px;
  	bottom:40px;
  	top: 80px;
  	margin-left: 30%;
}
#modal_form #modal_close {
  width: 21px;
  height: 21px;
  position: absolute;
  top: 10px;
  right: 10px;
  cursor: pointer;
  display: block;
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mikhail Osher, 2015-05-19
@maxprof

1) Check that there are no img related styles within the map container. stumbled upon such a rake.
2) Set a fixed height to the block.
3) Redraw the map. Also, always call this method when resizing the window (window resize).
google.maps.event.trigger(MapInstance,'resize')

V
vovastradamus, 2015-05-28
@vovastradamus

I myself have already answered a similar question. This is due to the fact that the maps are loaded when the page is generated, and the size is set smaller, so the map needs to be initialized again.
Pieces of a Google map in the upper left corner. How to display the map on the whole block?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question