- added geolocation API
- loader gif now local
This commit is contained in:
parent
b141b5bb8f
commit
8df8f9b92f
4 changed files with 29 additions and 16 deletions
41
index.html
41
index.html
|
|
@ -121,21 +121,13 @@
|
|||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="lon">Your Location</label>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="offset">Automatic Geolocation</label><br />
|
||||
<button id="locate" class="btn btn-default"><span class="glyphicon glyphicon-map-marker"></span> Locate Me</button>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="lon">Manual Geolocation</label>
|
||||
<input type="text" autocomplete="off" id="search" class="address form-control args" placeholder="City"/>
|
||||
|
||||
<!--
|
||||
* OSMnames autocomplete
|
||||
*-->
|
||||
<script>
|
||||
var autocomplete = new kt.OsmNamesAutocomplete(
|
||||
'search', 'https://geocoder.tilehosting.com/', 'kqIwOXlhKKgBoR5zVAnm');
|
||||
autocomplete.registerCallback(function(item) {
|
||||
SL.Calendar.getGeoCode(item);
|
||||
});
|
||||
</script>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
|
@ -289,6 +281,27 @@
|
|||
timestamp = $(this).data("DateTimePicker").date().utc().unix();
|
||||
});
|
||||
|
||||
// get browser location when button "locate" is clicked
|
||||
$("#locate").on("click", function() {
|
||||
if (navigator.geolocation) {
|
||||
navigator.geolocation.getCurrentPosition(function(position) {
|
||||
var item = {
|
||||
lat: position.coords.latitude,
|
||||
lon: position.coords.longitude
|
||||
}
|
||||
SL.Calendar.getGeoCode(item);
|
||||
});
|
||||
} else {
|
||||
alert("Geolocation is not supported by this browser.");
|
||||
}
|
||||
});
|
||||
|
||||
// OSMNAmes OsmNamesAutocomplete
|
||||
var autocomplete = new kt.OsmNamesAutocomplete('search', 'https://geocoder.tilehosting.com/', 'kqIwOXlhKKgBoR5zVAnm');
|
||||
autocomplete.registerCallback(function(item) {
|
||||
SL.Calendar.getGeoCode(item);
|
||||
});
|
||||
|
||||
// "About" modal
|
||||
$('#about').on('click', SL.Calendar.about);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue