cbeloch / locate Goto Github PK
View Code? Open in Web Editor NEWLocate is a MooTools class to make usage of the new HTML5 Location Feature
Home Page: http://locate.cbeloch.de
Locate is a MooTools class to make usage of the new HTML5 Location Feature
Home Page: http://locate.cbeloch.de
For cleaner code the base class "Locate" should not implement more functions than needed. Think of the mootools philosophy. Please implement "distanceTo" in an extended "Locate" class.
Number.extend({
// Converts the number in degrees to the radian equivalent
deg2rad: function(angle){
return (angle / 180) * Math.PI;
}
});
Location.Measure = {
OFFSET: 268435456,
RADIUS: 85445659.4471, // offset / PI
// Distance between two points on earth can be calculated in several ways.
// Haversine formula is reasonably accurate and widely used.
haversineDistance: function(lat1, lng1, lat2, lng2){
var latd = Number.deg2rad(lat2 - lat1);
var lngd = Number.deg2rad(lng2 - lng1);
var a = Number.sin(latd / 2) * Number.sin(latd / 2) +
Number.cos(Number.deg2rad(lat1)) * Number.cos(Number.deg2rad(lat2)) *
Number.sin(lngd / 2) *
Number.sin(lngd / 2);
var c = 2 * Number.atan2(Number.sqrt(a), Number.sqrt(1 - a));
return 6371.0 * c;
},
lngToX: function(lng){
return Number.round(this.OFFSET + this.RADIUS * lng * Math.PI / 180);
},
latToY: function(lat){
return Number.round(this.OFFSET -
this.RADIUS *
Number.log((1 + Number.sin(lat * Math.PI / 180)) /
(1 - Number.sin(lat * Math.PI / 180))) /
2);
},
pixelDistance: function(y1, x1, y2, x2, zoom){
if (y1 == y2 && x1 == x2)
return 0;
return Number.sqrt(Number.pow((x1 - x2), 2) + Number.pow((y1 - y2), 2)) >> (21 - zoom);
}
}
greetings André
Locate.js stopped working, throwing an error "Timout expired" in current iPhone OS 4.0 Beta 1
Firefox 3.6 Mac does work, but Windows doesn't.
Also Firefox 3.5 for Windows works.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.