ebidel / geo-location

Web component element for the Geolocation API
https://webcomponents.org/element/ebidel/geo-location
86 stars 25 forks source link

Fallback for Timeouts? #2

Closed joewxboy closed 10 years ago

joewxboy commented 10 years ago

Since your code has a five-second timeout, it is likely that devices will timeout before resolving location, especially with the accuracy turned up. Have you considered adding a backstop JSON service to perform IP-based geolocation if the initial resolution fails?

ebidel commented 10 years ago

Timeout is configurable https://github.com/ebidel/geo-location/blob/master/geo-location.html#L122. What do you mean by a JSON fallback?

joewxboy commented 10 years ago

At weather.com, they use their JSONP service to resolve a location when a browser does not support geolocation (usually <=IE8, which is not a problem in Polymer), or when geolocation fails (timeout, error, etc). An example call is http://gip.imwx.com/wxdata/gip/get.js?cb=jsonCallback

This approach guarantees a mostly-correct location for most users most of the time. I believe the Google Maps API v3 does something similar at http://maps.googleapis.com/maps/api/js?client=[clientid]&sensor=false&v=3.13

ebidel commented 10 years ago

Nice. I didn't know about that. Do you know if there's an available endpoint that is openly available to use?

joewxboy commented 10 years ago

I don't know of any public endpoints with both quality data and a decent SLA. Maybe just allow implementers to subscribe to the error event handler and code the backstop themselves? Then they can use whatever service they need, rather than trying to bake a substandard solution into the Element (unless Google releases a high-quality free service).

ebidel commented 10 years ago

Yea, I think that's the right approach. Users can use the error event to do what's best for them. Thanks for bringing this to my attention. I've filed https://github.com/ebidel/geo-location/issues/4 to track making timeout easier to configure.