javascript location based applications
mobile application development seems to be the new craze and everyone is getting in on it. with so many different platforms its difficult to decide which platform to code for. there are a few frameworks out there like Appcelerator and PhoneGap that enable you to write the application in JavaScript, HTML5 and CSS3 and then wrap the application in a ‘native’ shell to run on multiple platforms but you still need all the SDKs to do so. since all major phones have modern browsers you can create any web application using the 3 web languages instead. since geolocation seems to be the hip thing that all mobile apps have you need a way to make location based software. luckily the w3c has a new standard for doing so that is part of javascript and functions in most modern browsers:
navigator.geolocation
to make sure that the browser supports it wrapping the line in an if() statement will make sure that the application wont try to do something its incapable of doing. then once you know geolocation works, write your code:
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
alert('You are at' + position.coords.latitude + ' x ' + position.coords.longitude);
}
}
once you know the coordinates you can do all sorts of things: look up near by restaurants, get directions, find the closest gas station. now all you need to do is create a css that looks good on mobile devices and make the website itself the app. on an iphone its easy to save a website as a book mark on the home screen, so effectively you have created a location based application using only javascript, html5, and css3!




