Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Alfakhori
M4labplatform
Commits
3244c7e5
Commit
3244c7e5
authored
Aug 03, 2021
by
patri
Browse files
get my position feature
parent
781d3312
Changes
2
Hide whitespace changes
Inline
Side-by-side
vcm/index.html
View file @
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>
...
...
vcm/js/favoriteplaces.js
View file @
3244c7e5
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment