Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
hdastageeri
hft_awado_app
Commits
acc6587e
Commit
acc6587e
authored
Nov 25, 2019
by
Rron Jahja
Browse files
Initial Commit
parent
e67c971d
Changes
83
Hide whitespace changes
Inline
Side-by-side
src/app/home/home.page.ts
View file @
acc6587e
import
{
Component
}
from
'
@angular/core
'
;
import
{
Component
,
OnInit
,
ViewChild
,
ElementRef
}
from
'
@angular/core
'
;
import
{
Geolocation
}
from
'
@ionic-native/geolocation/ngx
'
;
declare
var
H
:
any
;
@
Component
({
selector
:
'
app-home
'
,
templateUrl
:
'
home.page.html
'
,
styleUrls
:
[
'
home.page.scss
'
],
})
export
class
HomePage
{
private
platform
:
any
;
@
ViewChild
(
"
map
"
,
{
static
:
false
})
public
mapElement
:
ElementRef
;
public
constructor
(
private
geolocation
:
Geolocation
)
{
this
.
platform
=
new
H
.
service
.
Platform
({
'
apikey
'
:
'
tiVTgBnPbgV1spie5U2MSy-obhD9r2sGiOCbBzFY2_k
'
});
}
public
ngOnInit
()
{
}
public
ngAfterViewInit
()
{
setTimeout
(()
=>
{
this
.
loadmap
();
},
1000
);
}
loadmap
(){
// Obtain the default map types from the platform object
var
defaultLayers
=
this
.
platform
.
createDefaultLayers
();
let
map
=
new
H
.
Map
(
this
.
mapElement
.
nativeElement
,
defaultLayers
.
vector
.
normal
.
map
,
{
zoom
:
15
,
center
:
{
lat
:
40.757601
,
lng
:
-
73.985328
},
pixelRatio
:
window
.
devicePixelRatio
||
1
}
);
var
behavior
=
new
H
.
mapevents
.
Behavior
(
new
H
.
mapevents
.
MapEvents
(
map
));
var
ui
=
H
.
ui
.
UI
.
createDefault
(
map
,
defaultLayers
);
this
.
getLocation
(
map
);
}
constructor
()
{}
getLocation
(
map
)
{
this
.
geolocation
.
getCurrentPosition
(
{
maximumAge
:
1000
,
timeout
:
5000
,
enableHighAccuracy
:
true
}
).
then
((
resp
)
=>
{
let
lat
=
resp
.
coords
.
latitude
let
lng
=
resp
.
coords
.
longitude
console
.
log
(
lat
);
console
.
log
(
lng
);
this
.
moveMapToGiven
(
map
,
lat
,
lng
);
},
er
=>
{
alert
(
'
Can not retrieve Location
'
)
}).
catch
((
error
)
=>
{
alert
(
'
Error getting location -
'
+
JSON
.
stringify
(
error
))
});
}
moveMapToGiven
(
map
,
lat
,
lng
)
{
map
.
setCenter
({
lat
:
lat
,
lng
:
lng
});
map
.
setZoom
(
14
);
}
}
src/assets/images/bike2gologo.png
0 → 100644
View file @
acc6587e
10 KB
src/index.html
View file @
acc6587e
...
...
@@ -7,7 +7,8 @@
<base
href=
"/"
/>
<meta
name=
"viewport"
content=
"viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"
/>
<meta
name=
"viewport"
content=
"viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"
/>
<meta
name=
"format-detection"
content=
"telephone=no"
/>
<meta
name=
"msapplication-tap-highlight"
content=
"no"
/>
...
...
@@ -20,6 +21,11 @@
<body>
<app-root></app-root>
<script
src=
"https://js.api.here.com/v3/3.1/mapsjs-core.js"
type=
"text/javascript"
charset=
"utf-8"
></script>
<script
src=
"https://js.api.here.com/v3/3.1/mapsjs-service.js"
type=
"text/javascript"
charset=
"utf-8"
></script>
<script
src=
"https://js.api.here.com/v3/3.1/mapsjs-ui.js"
type=
"text/javascript"
charset=
"utf-8"
></script>
<script
type=
"text/javascript"
src=
"https://js.api.here.com/v3/3.1/mapsjs-mapevents.js"
></script>
</body>
</html>
</html>
\ No newline at end of file
Prev
1
2
3
4
5
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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