freezy0001
freezy0001

Reputation: 23

How to set the camera always to the center of the user's Geolocation

How can I solve that the camera always follow the user's Geolocation? I tried this, but it doesn't work:

trackuserlocationstart.trigger();

Sorry, but I'm really newbie in this.

Upvotes: 0

Views: 70

Answers (1)

Steve Bennett
Steve Bennett

Reputation: 126235

It should be as easy as this:

if (navigator.geolocation) {
    navigator.geolocation.watchPosition(({ latitude, longitude }) => {
        map.panTo([longitude, latitude]);
    });
};

Upvotes: 1

Related Questions