Daemedeor
Daemedeor

Reputation: 1007

Google Maps 404 Error

I'm using google chart maps however, when I try to draw the map, it logs several errors of 404 to their server. however, I'm pretty sure i'm using the API correctly. The only information relating to this I could find was when people were using the old undocumented API at maps.google.com, which doesn't happen on their tutorial page. I can't figure out what I'm doing wrong? Code and console below for reference: Google maps error

google.load('visualization', '1', { 'packages': ['map'] });
google.setOnLoadCallback(drawGoogleMap);

function drawGoogleMap() {
  var data = google.visualization.arrayToDataTable([
    ['Lat', 'Long'],
    [21.3117, -157.8]
  ]);

  var options = {
    enableScrollWheel: true,
    useMapTypeControl: true
  };

  var map = new google.visualization.Map(document.getElementById("main"));

  map.draw(data, options);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1','packages':['map']}]}"></script>

<div id="main" class="chart_div container">
 

</div>

Upvotes: 2

Views: 4087

Answers (1)

Dr.Molle
Dr.Molle

Reputation: 117354

You didn't do anything wrong.

The issue: the API tries to draw all the markers inside the viewport. To be able to achieve it, the API calculates the zoomlevel. With a single marker as in your example it will use the maximum zoom(seems to be 22, note the z-parameter in the broken URLs). When the API loads a tile it didn't check if a tile exists(so it may happen that the request returns a 404, it happens very often)

Later the API requests the ViewPortService(you'll also see the request in the network-tab). This request returns informations about available data for the given ViewPort, especially available tiles(e.g. satellite-images).

After this request you will see further requests to URLs similar to the broken URLs, but with a different z-parameter(e.g. 20). It means: the ViewPortService has detected that for the given ViewPort satellite-images only be available for zoom 20, so the zoom of the map will be set to 20 and now the tiles may be loaded.

Just ignore the 404s

Upvotes: 4

Related Questions