I am trying to build a simple app. On the index.html page an input box and button. I put address in, click box to geocode and output some maps. When I click on the button, the geocoding seems to work (see chrome output below), but it does not bring up the testing URL.
This is what I get from chrome when I click on the button in the index.html, but nothing else happens. I bolded what I believe should redirect to the testing UR with the lng and lat data.
Request URL:
Request Method:
GET
Status Code:
200 OK
Any ideas would be helpful.
Ivan
index.html
...
<script>
var geocoder
function searchAddress()
{
var address = document.getElementById("address").value;
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
$.get("{% url 'testing' %}",
var position: results[0].geometry.location
{
lat: position.lat(),
lng: position.lng()
}
});
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
</script>
<input id=address value='Toronto, ON'>
<input id=searchAddress type=button value='Where are you'>
APP\urls.py
urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^output/$', views.output, name='output'),
url(r'^testing/$', views.testing, name='testing'),
]
views.py
def index(request):
return render(request, 'locator/index.html')
def testing(request):
searchpoint = Point(float(request.GET.get('lon')), float(request.GET.get('lat')))
atminfo = AtmInfo.objects.all()[:3]
locations = AtmInfo.objects.distance(searchpoint).transform().order_by('distance')[:3]
context = {'atminfo': atminfo, 'locations': locations, 'mainpnt': mainpoint}
return render(request, 'locator/testing.html', context)