Mercurial > public > sg101
view bandmap/static/js/bandmap.js @ 824:704b47356a49
Bandmap WIP: made a start on view unit tests.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 24 Sep 2014 21:22:24 -0500 |
parents | 71db8076dc3d |
children | 5103edd3acc4 |
line wrap: on
line source
var bandmap = null; var geocoder = null; function addBandOnSubmit(event) { var location = $('#id_location').val(); if (!location) { alert("Please enter a location"); return false; } var button = $(this); button.attr('disabled', 'disabled'); var form = $('#bandmap-add-form'); geocoder.geocode({'address': location}, function(results, status) { button.removeAttr('disabled'); if (status == google.maps.GeocoderStatus.OK) { $('#id_lat').val(results[0].geometry.location.lat().toString()); $('#id_lon').val(results[0].geometry.location.lng().toString()); $(form).submit(); } else { var msg = "Geocode unsuccessful: " + status + "\n" + "Enter a new location"; alert(msg); } }); return false; } $(document).ready(function() { var map_div = $('#map-canvas'); if (map_div.length) { var map_options = { center: {lat: 15.0, lng: -30.0}, zoom: 2 }; bandmap = new google.maps.Map(map_div[0], map_options); } var add_form = $('#bandmap-add-form'); if (add_form.length) { geocoder = new google.maps.Geocoder(); $('#bandmap-add-submit').click(addBandOnSubmit); } });