codeforamerica / MuniciPal

:speech_balloon: Consulting city-dwellers about legislation near them.
22 stars 14 forks source link

look into potential bug where image from council member stays from district #70

Open tbuckl opened 10 years ago

tbuckl commented 10 years ago

from the district one is in when one changes district with map drag.

techieshark commented 10 years ago

So if you switch from one district to another, is the problem that the councilmember photo for the previous district never updates, or that there is a lag between dragging the marker and updating the photo?

@ianmesa do you see this?

ianmesa commented 10 years ago

Ive seen both occur. However, the lag is seems to be more common than never updating to the new photo.

techieshark commented 9 years ago

Part of the lag here is due to network delays. When you drag the marker from one district to another, the frontend queries the server with the new lat/lng pair, and the server in turn asks the ESRI server what district that point is in and upon learning the district number the server shares that with the frontend.

A few technical options on speeding this up:

  1. Instead of using ESRI's cloud service to figure out what district contains a point, use PostGIS. We can rule this out for now, since we're trying to make this work with ESRI's stuff (but if we support PostGIS in the future again, this could be helpful).
  2. Send the query directly from the browser to ESRI. By dropping the server between the browser and ESRI, we'd cut the number of trips from four (browser -> heroku, heroku -> esri, esri -> heroku, heroku -> browser) to two (browser -> esri, esri -> browser). But on second thought, you'd still have the same number of trips, because after the browser gets the district # from esri, the browser would have to request all the server's resources associated with that district, which adds back a couple trips. That said, since we could cache the requests to heroku, this method would give improvements for users who select multiple locations and then come back to them.
  3. Finally, since we have the districts anyway, we could do point-in-polygon queries on the front end using the boundary data for the districts.