Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Maps not working in Django template on App Engine development server
    primarykey
    data
    text
    <p>When I add this script to a plain HTML file's HEAD section</p> <pre><code>&lt;script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"&gt;&lt;/script&gt; </code></pre> <p>and I run this script on the body onload, </p> <pre><code>function initialize() { var latlng = new google.maps.LatLng(-34.397, 150.644); var myOptions = { zoom: 8, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); } </code></pre> <p>then I see the Google map just fine.</p> <p>However, the same does not work when in a Django template. (Yes, I am new to Django :) I get all the code in the initialize function to run, but no map shows up. Page stays blank.</p> <p>I assume it has something to do with Django, and the GAE dev server, and how the Google Maps js API is referenced, but I don't know how to fix.</p> <p>Thanx much.</p> <p>Edit:</p> <p>My Django template looks like this (There are no Django specific tags or anything yet.)</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" xml:lang="en" lang="en"&gt; &lt;head&gt; &lt;meta name="viewport" content="initial-scale=1.0, user-scalable=no" /&gt; &lt;link rel="stylesheet" type="text/css" href="/site_media/css/reset.css" /&gt; &lt;link rel="stylesheet" type="text/css" href="/site_media/css/main.css" /&gt; &lt;script src="/site_media/js/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function(event) { initialize(); }); function initialize() { var latlng = new google.maps.LatLng(-34.397, 150.644); var myOptions = { zoom: 8, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;br/&gt; &lt;br/&gt; &lt;br/&gt; &lt;br/&gt; &lt;br/&gt; &lt;br/&gt; &lt;center&gt; &lt;div id="map_canvas" style="width:60%; height:70%;"&gt;Why the heck is the map not showing?&lt;/div&gt; &lt;/center&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>And the rendered HTML source of that template from the browser looks like this:</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" xml:lang="en" lang="en"&gt; &lt;head&gt; &lt;meta name="viewport" content="initial-scale=1.0, user-scalable=no" /&gt; &lt;title&gt;&lt;/title&gt; &lt;link rel="stylesheet" type="text/css" href="/site_media/css/reset.css" /&gt; &lt;link rel="stylesheet" type="text/css" href="/site_media/css/main.css" /&gt; &lt;script src="/site_media/js/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function(event) { initialize(); }); function initialize() { var latlng = new google.maps.LatLng(-34.397, 150.644); var myOptions = { zoom: 8, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;br/&gt; &lt;br/&gt; &lt;br/&gt; &lt;br/&gt; &lt;br/&gt; &lt;br/&gt; &lt;center&gt; &lt;div id="map_canvas" style="width:60%; height:70%;"&gt;Why the heck is the map not showing?&lt;/div&gt; &lt;/center&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload