Auto-center map with multiple markers in Google Maps API v3

This is what I use to display a map with 3 pins/markers: <script> function initialize() { var locations = [ [‘DESCRIPTION’, 41.926979, 12.517385, 3], [‘DESCRIPTION’, 41.914873, 12.506486, 2], [‘DESCRIPTION’, 41.918574, 12.507201, 1] ]; var map = new google.maps.Map(document.getElementById(‘map’), { zoom: 15, center: new google.maps.LatLng(41.923, 12.513), mapTypeId: google.maps.MapTypeId.ROADMAP }); var infowindow = new google.maps.InfoWindow(); var marker, … Read more

Selecting last element in JavaScript array [duplicate]

This question already has answers here: Get the last item in an array (58 answers) Closed 5 years ago. I’m making an application that updates a user’s location and path in real time and displays this on a Google Map. I have functionality that allows multiple users to be tracked at the same time using … Read more