Evangelism/Firefox3.5/35Days/Articles/geolocationDemo: Difference between revisions

Jump to navigation Jump to search
Line 13: Line 13:
   var lat1 = aLatitude*Math.PI/180;
   var lat1 = aLatitude*Math.PI/180;
   var lon1 = aLongitude*Math.PI/180;
   var lon1 = aLongitude*Math.PI/180;
   // Point at 45° North East
   // Point at 45° North East
   var brng = 45*Math.PI/180;
   var brng = 45*Math.PI/180;
Line 24: Line 23:
   lat2 =lat2*180/Math.PI;
   lat2 =lat2*180/Math.PI;
   lon2 =lon2*180/Math.PI;
   lon2 =lon2*180/Math.PI;
  // Point at 45° South West
  var brng = 225*Math.PI/180;
  var lat3 = Math.asin( Math.sin(lat1)*Math.cos(aAccuracy/R) +
                        Math.cos(lat1)*Math.sin(aAccuracy/R)*Math.cos(brng) );
  var lon3 = lon1 +
              Math.atan2( Math.sin(brng)*Math.sin(aAccuracy/R)*Math.cos(lat1),
                          Math.cos(aAccuracy/R)-Math.sin(lat1)*Math.sin(lat3));
  lon3 = (lon3+Math.PI)%(2*Math.PI) - Math.PI;
  lat3 =lat3*180/Math.PI;
  lon3 =lon3*180/Math.PI;
  // return the extent
  return {north:lat2,south:lat3,east:lon2,west:lon3};
  }
  }


Une fois que nous connaissons cet extent, the map is zoom to extent (center to the position with a precision reflecting the accuracy) and we query GeoNames to know geolocalised wikipedia's article and places inside the accuracy extent. If the accuracy is less than 1000 meters, we used to query GeoNames an accuracy extent based on an accuracy of 1000 meters.
Une fois que nous connaissons cet extent, the map is zoom to extent (center to the position with a precision reflecting the accuracy) and we query GeoNames to know geolocalised wikipedia's article and places inside the accuracy extent. If the accuracy is less than 1000 meters, we used to query GeoNames an accuracy extent based on an accuracy of 1000 meters.
19

edits

Navigation menu