function getCurrentLocationMapLink (callback) {
getCurrentLocation(function (pos) {
var lat = pos.coords.latitude;
var lon = pos.coords.longitude;
var q = lat + ',+' + lon;
var uri = 'http://maps.google.co.jp/maps?q=' + q + '&iwloc=A&hl=ja';
callback(uri);
});
}
function getCurrentLocation (callback) {
var geo = navigator.geolocation || google.gears.factory.create('beta.geolocation');
var dialog = createElementFromString(
['<div class="overlay">',
'<div class="content">',
'<span class="message">GPS Fixing...</span><input type="button" value="Cancel" class="cancel"/>',
'</div>',
'</div>'].join(''), {
parent: document.body
}
);
dialog.setAttribute('style', 'color: #fff; background: #000; opacity: 0.9; position: absolute; top: 0; left: 0;');
dialog.style.height = (document.documentElement.scrollHeight) + 'px';
dialog.style.width = (document.documentElement.scrollWidth) + 'px';
dialog.content.setAttribute('style', 'position: absolute; text-align: center; vertical-align: 50%; width: 100%;');
dialog.content.style.lineHeight = (window.innerHeight) + 'px';
dialog.content.style.top = (window.pageYOffset) + 'px';
document.body.style.overflow = 'hidden';
var id = geo.watchPosition(
function (pos) {
geo.clearWatch(id);
callback(pos);
dialog.parentNode.removeChild(dialog);
},
function (e) {
},
{
enableHighAccuracy: true,
maximumAge: 0,
gearsLocationProviderUrls: []
}
);
dialog.cancel.addEventListener('click', function (e) {
document.body.style.overflow = 'visible';
geo.clearWatch(id);
dialog.parentNode.removeChild(dialog);
}, false);
dialog.cancel.focus();
}