I am making a custom map in my application. Which is essentially a large map image where I move a small avatar image over the large map image based on a gps location.
I allow the user to scroll around the map to look at places off the screen.
I now want to include a button which will center the user back on their location. but it is not working, I have tried using:
window.moveTo()
window.scrollTo()
but nothing happens. Can anyone assist with this?
html
<ion-content padding id=ionScroll scrollX="true" scrollY="true">
<div id = "main" >
<img class = "map"
id = "map"
src = "../../assets/img/limerickmap.JPG"
alt = "map"/>
<img class = "avatar"
id = "avatar"
src = "../../assets/img/satan.png"
alt = "avatar" />
</div>
<ion-fab vertical="bottom" horizontal="end" slot="fixed">
<ion-fab-button (click) = "centreMap()">
<ion-icon name="compass"></ion-icon>
</ion-fab-button>
</ion-fab>
</ion-content>
Typescript
ngOnInit() {
ionScroll = window.document.getElementById("ionScroll");
}
centreMap() {
ionScroll.scrollTo(avatar.style.left , avatar.style.top);
console.log("TEST scroll" +avatar.style.left+" "+avatar.style.top)
}