"geao localisation"
Bootstrap 3.0.0 Snippet by evarevirus

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<h1>A super-simple geolocatio·n example</h1>
<i class="fa fa-map-marker"></i>
<button class="pure-button pure-button-primary">Get my location</button>
<div class="result"></div>
<span>see link in "details" for more information</span>
<script>
/** NOTE: uses jQuery for quick & easy DOM manipulation **/
function getLocation(){
var msg;
/**
first, test for feature support
**/
if('geolocation' in navigator){
// geolocation is supported :)
requestLocation();
}else{
// no geolocation :(
msg = "Sorry, looks like your browser doesn't support geolocation";
outputResult(msg); // output error message
$('.pure-button').removeClass('pure-button-primary').addClass('pure-button-success'); // change button style
}
/***
requestLocation() returns a message, either the users coordinates, or an error message
**/
function requestLocation(){
/**
getCurrentPosition() below accepts 3 arguments:
a success callback (required), an error callback (optional), and a set of options (optional)
**/
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
@import url(http://fonts.googleapis.com/css?family=Open+Sans:400);
@import url(//netdna.bootstrapcdn.com/font-awesome/4.0.0/css/font-awesome.css);
@import url(http://yui.yahooapis.com/pure/0.3.0/pure-min.css);
html{
background: #222;
}
body{
background: #fff;
font-family: 'Open Sans', sans-serif;
max-width: 380px;
border: 1px solid #ccc;
border-radius: 5px;
box-shadow: 0 0 1px #000;
margin: 1em auto;
padding: 0 1em 1em 1em;
text-align: center;
}
.fa-map-marker{
width:100%;
font-size: 10em;
color: #cf483e;
text-shadow: 0 0 1px #000;
animation: bounce 1s linear 3;
}
button{
box-shadow: 0 0 1px #000;
}
.result{
margin: 2em 2em 1em 2em;
}
.result img{
margin-top: 1em;
border: 1px solid #333;
}
.fa-spinner{
font-size: 3em;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments: