How to serialize data from a href values?

I created a code based on two examples in Stack, the mixture of the two gets:

* By clicking on a href pan to new position
* Generate markers with loop "for"

I would understand how I can serialize a href values to automatically generate the markers to avoid writing twice geolocation code.

Any ideas? thanks

```
<html>
<a name="locations"></a>
<ul>
    <li><a class="location_class" data-location_phi="41.3947901,2.1487679">Barcelona</a></li>
    <li><a class="location_class" data-location_phi="41.1258048,1.2385834">Tarragona</a></li>
</ul>
<div id="testmap"></div>
</html>

<script>
var locations = [
  ['loan 1', 41.3947901,2.1487679, 'address 1', 'some1'],
  ['loan 2', 41.1258048,1.2385834, 'address 2', 'some2']
  ];

function pan_func(latlon) {
    var coords = latlon.split(",");
    var panPoint = new google.maps.LatLng(coords[0], coords[1]);
    map.panTo(panPoint);
}

function setMarkers(map,locations){
    var marker, i;

    for (i = 0; i < locations.length; i++) {

        var loan = locations[i][0];
        var lat = locations[i][1];
        var longi = locations[i][2];
        var add =  locations[i][3];
        var add_phi =  locations[i][4];
        var latlngset = new google.maps.LatLng(lat, longi);

        marker = new google.maps.Marker({  
            map: map,
            title: loan,
            position: latlngset
        });
        var content = "<h3>Loan Number: " + loan +  '</h3>' + "Address: " + add + add_phi; 
        var infowindow = new google.maps.InfoWindow();
        google.maps.event.addListener(marker,'click', phi_test(marker,content,infowindow)); 

    }

    function phi_test (marker,content,infowindow){ 
        return function() {
            infowindow.setContent(content);
            infowindow.open(map,marker);
            map.panTo(marker.getPosition());
         };
     }
}

var map;

function initialize() {
    var mapOptions = {
        zoom: 8,
        center: new google.maps.LatLng(41.3947901,2.1487679),
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById('testmap'), mapOptions);

    $('.location_class').on('click', function () {
        pan_func($(this).data('location_phi'));
    });
    setMarkers(map,locations);
}

google.maps.event.addDomListener(window, 'load', initialize);
</script>

```

[Demo here](https://jsfiddle.net/thetipico/9Lemwp07/6/)