Exemplo n.º 1
0
def sitios_cerca(request):
    latitud = request.GET['latitud']
    longitud = request.GET['longitud']
    tipo_sitio = 'parking'
    radio = '0.01'
    sitios = json.dumps(
        geo.findNearestSites(latitud, longitud, tipo_sitio, radio))

    response = HttpResponse(sitios, content_type="application/json")
    response['Access-Control-Allow-Origin'] = '*'
    response['Access-Control-Allow-Headers'] = 'X-Requested-With'
    return response
Exemplo n.º 2
0
def sitios_por_dir(request):
    direccion = request.POST['direccion']
    tipo_sitio = request.POST['tipo_sitio']
    coord_direccion = geo.geocode(direccion)
    radio = '0.01'
    if not ('error' in coord_direccion ):

        sitios = json.dumps(
            geo.findNearestSites(coord_direccion['lat'], coord_direccion['lng'], tipo_sitio, radio))
        response = HttpResponse(sitios, content_type="application/json")
    else:
        error = 'Direccion desconocida'
        response = HttpResponse({'error': error}, content_type="application/json")
    
    response['Access-Control-Allow-Origin'] = '*'
    response['Access-Control-Allow-Headers'] = 'X-Requested-With'
    return response