mohamedmansour / hackathon-letsgo.io

letsgo.io - Photo Hack Day 4 project
http://letsgo.io
5 stars 6 forks source link

Use HTML5 Geo location Service for original mapping center #11

Closed mohamedmansour closed 11 years ago

mohamedmansour commented 11 years ago

When brought into the website, ask for permissions to use your location and post that as the first input (from) . So the user can enter just one input (to) that way the map would be more personalized.

justinormont commented 11 years ago

I think getting an IP based location is better. The accuracy is good enough, and we don't have to bother the user. This one is ok, but needs to be run server side. I'd prefer a client side one. http://freegeoip.net/

jeremybenaim commented 11 years ago

Server-side is faster though

jeremybenaim commented 11 years ago

I'll do that with a middleware

jeremybenaim commented 11 years ago
"Less XHR -> moar awesomeness"
-- a wise man
jeremybenaim commented 11 years ago

Cannot clone/commit anything but here the idea :

app.use(express.cookieParser()); 
app.use(express.session({ secret: 'keyboard cat' }));

app.get('/', setCityFromIp, function(req, res){
  res.render('index', { location: req.session.cityFromIp || 'nowhere' });
});

function setCityFromIp(req, res, next){
  req.session = req.session || {};

  if(typeof req.session.cityFromIp === 'undefined') {
    request('http://freegeoip.net/json/' + req.ip, function (error, response, body) {
      if (!error && response.statusCode == 200) {
        req.session.cityFromIp = JSON.parse(body).city;
        next();
      }
    });
  } else {
    next();
  }
}
jeremybenaim commented 11 years ago

This would trigger a request to the IP service for the first request, then store in into the session, so that we request the service only once

mohamedmansour commented 11 years ago

This will make our initial load depend on that external service. We should get an offline one that looks at IP map and returns the lat long.

Sent from my Windows 8 Phone


From: Jeremy Benaimmailto:notifications@github.com Sent: ‎4/‎8/‎2013 2:27 PM To: mohamedmansour/letsgo.iomailto:letsgo.io@noreply.github.com Cc: Mohamed Mansourmailto:mmansour@outlook.com Subject: Re: [letsgo.io] Use HTML5 Geo location Service for original mapping center (#11)

This would trigger a request to the IP service for the first request, then store in into the session, so that we request the service only once


Reply to this email directly or view it on GitHub: https://github.com/mohamedmansour/letsgo.io/issues/11#issuecomment-16079967

jthiller commented 11 years ago

At work we use MaxMind to get regions to send the user to the correct ecommence store.

MaxMind also has an open source set of data that might be worth looking into: http://dev.maxmind.com/geoip/geolite

mohamedmansour commented 11 years ago

@jthiller that would be a better approach because the in initial reaction is what counts. Performance matters for the initial payload.