 <p>I suggest to store coordinates and address info in data-attributes, obtaining more flexible code in result: need one more marker? — just add another &lt;a&gt;!</p> <pre><code>&lt;html&gt; &lt;ul&gt; &lt;li&gt; &lt;a href="#" class="location_class" data-location_phi="41.3947901,2.1487679" data-loan="loan 1" data-add="address 1" data-add_phi="some1"&gt;Barcelona&lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="#" class="location_class" data-location_phi="41.1258048,1.2385834" data-loan="loan 2" data-add="address 2" data-add_phi="some2"&gt;Tarragona&lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="#" class="location_class" data-location_phi="46.4841143,30.7388449" data-loan="" data-add="address 3" data-add_phi=""&gt;Odessa&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;div id="testmap"&gt;&lt;/div&gt; &lt;/html&gt; </code></pre> <p>JS</p> <pre><code>google.maps.event.addDomListener(window, 'load', initialize); function initialize() { var mapOptions = { zoom: 8, center: new google.maps.LatLng(41.3947901, 2.1487679), mapTypeId: google.maps.MapTypeId.ROADMAP } setMarkers( new google.maps.Map(document.getElementById('testmap'), mapOptions) ); } function setMarkers(map) { // Find links with "data-location_phi" attribute, // that contains coordinates required for marker placement var a = document.querySelectorAll('[data-location_phi]'); for (var i = 0; i &lt; a.length; i++) { // Create an instance of MapMarker class for every location link new MapMarker(map, a[i]); } } function MapMarker(map, a) { this.a = a; this.map = map; this.dataset = {}; this.fillDataSet(); // Since we don't validate data in attributes it may cause some exceptions try { var loc = this.dataset.location_phi.split(','); this.latLng = new google.maps.LatLng(loc[0], loc[1]); this.marker = new google.maps.Marker({ map: this.map, title: this.dataset.loan, position: this.latLng }); // Bind event listeners this.bind(); } catch (e) { console.log(e); } } MapMarker.prototype.fillDataSet = function () { var self = this; Array.prototype.slice.call(self.a.attributes).forEach(function (attr) { if (attr.name.substr(0, 5) == 'data-') { self.dataset[attr.name.substr(5)] = attr.value; } }); } MapMarker.prototype.panTo = function () { this.map.panTo(this.latLng); } MapMarker.prototype.showInfo = function () { var infowindow = new google.maps.InfoWindow(); var content = '&lt;h3&gt;Loan Number: ' + this.dataset.loan + '&lt;/h3&gt;' + 'Address: ' + this.dataset.add + this.dataset.add_phi; infowindow.setContent(content); infowindow.open(this.map, this.marker); } MapMarker.prototype.bind = function () { var self = this; // Click on the link self.a.addEventListener('click', function (e) { e.preventDefault(); self.panTo(); }); // Click on the marker google.maps.event.addListener( self.marker, 'click', function () { self.showInfo(); self.panTo(); } ); } </code></pre> <p><a href="https://jsfiddle.net/9Lemwp07/9/" rel="nofollow">Demo</a></p>