I need to make a map on a web page with markers that move according to the user's location on the map. like the uber in the map of the uber application.
try to do this but it looks bad.
var map;
function initMap() {
var myLatLng = app.ubicacion;
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 17,
center: myLatLng,
disableDefaultUI: true
});
setInterval(mar,250);
function mar() {
var image = 'img/taxi2.png'
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
title: app.username,
icon: image
});
setInterval(rem, 200)
function rem() {
marker.setMap(null);
}
console.log(myLatLng.lat)
}
}
in Spanish I create a marker and I delete it and create it again in case the location has been updated.
I would like to know if there is another way to do it?