Commit c230dc78 authored by Cholgrrr's avatar Cholgrrr
Browse files

Merge branch 'New_Structure' of https://gitlab.com/Cholgrrr/m4labplatform into New_Structure

parents 18a4c153 3244c7e5
......@@ -228,7 +228,8 @@
</p><br>
<img id="dragFrom" onmouseover="setPointStartEnd('fav')" ondragstart="dragstart_handler(event);" draggable=true src="templates/locationSM.png" style="height:30px;height: 30px; display: inline-block; position: absolute;cursor: -webkit-grab; cursor: grab;">
</div><br><br>
<label class="container contentOne">Andere Lieblingsorte
<button onclick="getLocationFav()">Aktuelle Position</button><br>
<br> <label class="container contentOne">Andere Lieblingsorte
<input type="checkbox" id="favcheck" onclick="switchFavPlaces()">
<span class="checkmark"></span>
</label>
......
......@@ -138,3 +138,49 @@ function switchFavPlaces(){
}
}
// Get Location of User
function getLocationFav() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPositionFav, showError);
} else {
console.log("Geolocation is not supported by this browser.");
}
}
function showPositionFav(position) {
console.log("Latitude: " + position.coords.latitude +
" Longitude: " + position.coords.longitude)
var pointd = {
lat:"",
lon:"",
loc:""
}
pointd.lat = position.coords.latitude
pointd.lon = position.coords.longitude
pointd.loc = "fav"
setPointFav("fav", pointd);
var viewpointFavLoc = new vcs.vcm.util.ViewPoint.createViewPointFromExtent([position.coords.longitude - 0.0005, position.coords.latitude - 0.0005, position.coords.longitude + 0.0005, position.coords.latitude + 0.0005])
viewpointFavLoc.pitch = -40
vcs.vcm.Framework.getInstance().getActiveMap().gotoViewPoint(viewpointFavLoc);
}
function showError(error) {
switch(error.code) {
case error.PERMISSION_DENIED:
console.log("User denied the request for Geolocation.")
break;
case error.POSITION_UNAVAILABLE:
console.log("Location information is unavailable.")
break;
case error.TIMEOUT:
console.log("The request to get user location timed out.")
break;
case error.UNKNOWN_ERROR:
console.log("An unknown error occured")
break;
}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment