{% extends "base.html" %}
{% load staticfiles %}

{% block head %}
<script src='https://maps.googleapis.com/maps/api/js'></script>
<script src='{% static "js/gmaps.js" %}'></script>
<script>
$(document).ready(function() {
    $('#enter_location').submit(function(e){
        e.preventDefault();
        GMaps.geocode({
            address: $('#address').val().trim(),
            callback: function(results, status){
                if ( status == 'OK' ){
                    var latlng = results[0].geometry.location,
                            lat = latlng.lat(),
                            lon = latlng.lng();
                    $.get('../get_latlon/', {
                        user: results.name,
                        lat: lat,
                        lon: lon,
                        address: address.value
                    }).always(function() {
                        location.reload();
                    });
                }
            }
        });
    });
});
</script>
{% endblock %}

{% block title %}Find Your Legislator{% endblock title %}
{% block subtitle %}Enter an address to find your Senator and Representative{% endblock subtitle %}

{% block content %}

{% include "preferences/location_form.html" %}

{% endblock content %}

{% extends "base.html" %}
{% load staticfiles %}

{% block head %}
<script src='https://maps.googleapis.com/maps/api/js'></script>
<script src='{% static "js/gmaps.js" %}'></script>
<script>
$(document).ready(function() {
    var map = new GMaps({
        div: '#map',
        lat: 38,
        lng: -97,
        zoom: 3
    });

    $('#enter_location').submit(function(e){
        e.preventDefault();
        GMaps.geocode({
            address: $('#address').val().trim(),
            callback: function(results, status){
                if ( status == 'OK' ){
                    var latlng = results[0].geometry.location,
                            lat = latlng.lat(),
                            lon = latlng.lng();
                    $.get('../get_latlon/', {
                        user: results.name,
                        lat: lat,
                        lon: lon,
                        address: address.value
                    }).always(function() {
                        location.reload();
                    });
                }
            }
        });
    });
});
</script>
{% endblock %}

{% block title %}Find Your Legislator{% endblock title %}
{% block subtitle %}Enter an address to find your Senator and Representative{% endblock subtitle %}

{% block content %}
<div id="map"></div>

{% include "preferences/location_form.html" %}

{% endblock content %}

Add map variable in JS
Add map variable in JS
