You Are Here:<br />
<img id='gmpsimg' />
<script type="text/javascript">
if (navigator.geolocation) {
var timeoutVal = 10 * 1000 * 1000;
navigator.geolocation.getCurrentPosition(
gmp,
showerror,
{ enableHighAccuracy: true, timeout: timeoutVal, maximumAge: 0 }
);
}
else {
alert("Geolocation is not supported by this browser");
}
function gmp(position) {
document.getElementById('gmpsimg').src =
'http://maps.googleapis.com/maps/api/staticmap?markers=color:blue%7Clabel:X%7C'
+ position.coords.latitude + ',' + position.coords.longitude +
'&zoom=17&size=400x400&sensor=true&maptype=hybrid';
}
function showerror(error) {
var errors = {
1: 'Permission denied',
2: 'Position unavailable',
3: 'Request timeout'
};
alert("Error: " + errors[error.code]);
}
</script>
20120425
simple js geolocation test
Nothing really special here, js Geolocation pulling a static google map image as a very simple example to test some browser settings. See the code below or run the example here.
Subscribe to:
Post Comments (Atom)
Firefox Feedly RSS option
If you use Firefox with a RSS button and want the default RSS page to offer a Feedly option here is what you need to do: go to the about:c...
-
Ever get stuck between two API and have to keep converting between two almost identical sets of data objects because neither API can be modd...
-
Working on something last week I thought it might be a good idea to have an attribute that added an extra endpoint to a service at runtime. ...
No comments:
Post a Comment