Showing posts with label IT. Show all posts
Showing posts with label IT. Show all posts

HTML5 Geolocation Demo

  • Monday, January 17, 2011
  • Posted by filial23
  • Labels: ,

This is a demonstration of HTML5 Geolocation. Your location will be shown on Google Maps after your permission.






First I thought standard Geolocation APIs would work with all browsers including Safari and Firefox and Chrome, however it's impossible to get correct positional data from Chrome for Windows. I solved this problem by using Google Gears which requires to switch the code based on browser type as below.

var userAgent = window.navigator.userAgent.toLowerCase();
var chrome = (userAgent.indexOf("chrome") != -1) ? true : false;

Then get positional data correctly both Chrome and Firefox as below. If you are not familiar with the getCurrentPosition() method, please check the specification on W3C.org.

var geolocation = (chrome) ?
google.gears.factory.create('beta.geolocation') :
navigator.geolocation;

geolocation.getCurrentPosition(
successCallback,
errorCallback);

Finally get latitude and longitude according to what the browser type is, because these are not affordable via the coords object with Chrome, plot the client's position on Google Maps: I implemented PositionCallback and PositionErrorCallback as below.

function successCallback(p) {
var lat = (chrome) ? p.latitude : p.coords.latitude;
var lng = (chrome) ? p.longitude : p.coords.longitude;
var pos = new google.maps.LatLng(lat, lng);

var map = new google.maps.Map(document.getElementById("gmap"), {
zoom : 16,
center : pos,
mapTypeId : google.maps.MapTypeId.ROADMAP
});

var marker = new google.maps.Marker({
position : pos,
map : map
});
}

function errorCallback(err) {
document.getElementById("msg").innerHTML =
"Error using Geolocation API: " + error.message;
}


I've check if this program works with the latest version of Safari for Mac and Firefox and Chrome for Windows.
  • Safari - Sometimes it works unstably and often fails to get positional data on Mac. This problem can be solved by quitting Safari once. Probably there might be a few glitches in the code.
  • Firefox - It works with both Windows and Mac well.
  • Chrome - Google Gears For Mac is unavailable in this moment so that it doesn't work with Chrome for Mac.
WinMac
Safari×○
Firefox○○
Chrome○×
IE××


HTML5 Powered

HTML5 Canvas Demo

  • Tuesday, January 11, 2011
  • Posted by Taka
  • Labels: ,

This is a sample of HTML5 Canvas. If the message 'HTML5 Canvas is not available on your browser.' doesn't appear, you can draw on the canvas below. You can change a color by clicking a color rectangle on the left hand. You can use a eraser by choosing white color.

Let's draw!




HTML5 Canvas is not available on your browser.


More than one person would be able to draw simultaneously and collaboratively from a distance as we can do on dabbleboard.com, if the browser transfers drawing data and scrolling data to the Websocket Server then the server pushes these data to other clients. But there is no Websocket Server available to connect from here and Websocket Client is not implemented on this page.

Easy Music Piracy

  • Saturday, October 16, 2010
  • Posted by Taka
  • Labels:

One of my interests is listening to music. I often watch music videos on Youtube and listen to music on jango. We can play almost all international music on jango. it's very useful but not secure. We can acquire URL of a mp3 file easily from a list of configuration files that your browser shows. It means you can download a mp3 file without paying for it. Of course it is music piracy, but I think jango is responsible for preventing music piracy, if they don't want to be done.

If music industry won't move with the times of digital age, some medium sized companies related to music in Japan will be bankrupt in next decade. It can be also said that those who want to make a break as famous artists in the future must come up with the new system to earn money and face directly how to deal with this trend.

I found a unique idea called Open Score Music which deal music like open source software. Do you agree with it?