0

When I am trying to use the search bar, the autofill just gives me " , , " and when I click on that suggestion the console tells me "invalid sw".

After reasearching the problem a bit, everyone seems to say "you're longitude and latitude aren't set up properly in the database" but I know that is not true. I have recreated the database 3 times. longitude and latitude are spelled correctly,and are set to numeric. I even added"search?q=xxxxx" to the end of my URL and copy/paste the lat/long from that into the 'center' attribute of the options method in scripts.js. When I load my URL with that lat/long, the map is on the correct town. So I know the format of the lat and long is correct.

I have no idea what else that Error could mean.

Here's the relevant code.Thanks!

The options from scripts.js:

let options = {
    center: {lat: 47.9017, lng: -122.2472}, // Stanford, California
    disableDefaultUI: true,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    maxZoom: 14,
    panControl: true,
    styles: styles,
    zoom: 13,
    zoomControl: true
};

my search from application.py:

q = request.args.get("q") + "%"
placesMatches = db.execute("SELECT * FROM places WHERE postal_code LIKE :q", q=q)
return jsonify([placesMatches])

my SQL query to create the places table:

CREATE TABLE 'places' ('country_code' TEXT,'postal_code' TEXT, 'place_name' 
TEXT, 'admin_name1' TEXT, 'admin_code1' TEXT, 'admin_name2' TEXT, 
'admin_code2' TEXT, 'admin_name3' TEXT, 'admin_code3' TEXT, 'latitude' 
NUMERIC, 'longitude' NUMERIC, 'accuracy' INTEGER)

The error:

ERROR:flask.app:Exception on /update [GET]
Traceback (most recent call last):
File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/app.py", 
line 2292, in wsgi_app

response = self.full_dispatch_request()
File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/app.py", 
line 1815, in full_dispatch_request

rv = self.handle_user_exception(e)
File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/app.py", 
line 1718, in handle_user_exception

reraise(exc_type, exc_value, tb)
File "/opt/pyenv/versions/3.6.0/lib/python3.6/site- 
packages/flask/_compat.py", line 35, in reraise
raise value

File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/app.py", 
line 1813, in full_dispatch_request

rv = self.dispatch_request()
File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/app.py", 
line 1799, in dispatch_request

return self.view_functions[rule.endpoint](**req.view_args)
File "/home/ubuntu/workspace/pset8/mashup/application.py", line 59, in 
update

raise RuntimeError("invalid sw")
RuntimeError: invalid sw
1

A list of a list. Program expects a list of places. execute returns a list of rows. This

return jsonify([placesMatches])

(specifically the []) nests placesMatches into another list.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .