Refresh marker google maps on apache server

Refresh marker google maps on apache server

Can't refresh marker only. Without refreshing whole google map. Location is sent every 10 seconds from esp32 to apache server. I just can't refresh markers only. The only way to refresh marker position is to refresh whole map0 which is not my goal. I'd like to refresh only markers without reloading whole map or website.

Please HELP. =)

<?php foreach($rows as $row){ ?>


    var location = new google.maps.LatLng(<?php echo $row['lat']; ?>, <?php echo $row['lng']; ?>);
    function refreshMarker(){

// if marker exists and has a .setMap method, hide it
  function SetMarker(location, map) {
    //Remove previous Marker.
    if (marker == null) {
        marker.setMap(null);
    }
}
    //marker.setMap(map);
    var marker = new google.maps.Marker({
        position: location,
        icon: betw,
        title:"<?php echo $row['lat']; ?>, <?php echo $row['lng']; ?> , <?php echo $row['time']; ?> , <?php echo $row['altitude']; ?> m, <?php echo $row['speed']; ?> km/h, <?php echo $row['temperature']; ?> °C",
        map: map
    });
    
 setTimeout(refreshMarker, 1000);}
 refreshMarker();

            
<?php } ?>  

Answer

I was able to get the result from chat gpt. UAU. I'm amazed... I suggest you do the same. If your questions are precise CHAT GPT will give you a working solution... I should do that more often =)

Enjoyed this question?

Check out more content on our blog or follow us on social media.

Browse more questions