0

The Preamble

I want to create a list of google map markers which populate InfoWindows about those specific locations and inside the InfoWindow a link to the Wikipedia article about that location. I am making an Ajax call within this google.maps.event.addListener(place.marker, 'click', function() {} click function, and this function is within a self.allPlaces().forEach(function(place) {} function that just iterates through all my locations.

The Problem

The link is populated within the InfoWindows, but it only opens if you right click and open in a new tab, whereas I would like it to just open with a left click.

function ajax() {
            return $.ajax({
                type: 'GET',
                url: wikiURL,
                dataType: "jsonp",
                prop: 'pageimages'
            });
        }

        ajax().done(function(response) {
            clearTimeout(self.apiTimeout);
            var articleList = response[1];
            console.log(response);
            if (articleList.length > 0) {
                for (var i = 0; i < articleList.length; i++) {
                    var url = response[3]; // response[3] gives back the wiki URL
                    content = '<div class="infoWindow"><strong>' + place.title + '</strong><br>' +
                                '<p>' + place.formatted_address + '</p>' +
                                '<p>' + response[2] + '</p>' + // response[2] for more modern response
                                '<a href="' + url + '" target="_blank">' +
                                "View full Wikipedia article" + '</a>' +
                    '</div>';
                    infoWindow.setContent(content);
                }
            }
Community
  • 1
  • 1
Caden Albaugh
  • 213
  • 4
  • 10

1 Answers1

0

I think your implementation might do something with the error. Check if the created content variable look like the code sample contentString variable

Try and follow the sample code in the link.

Code Sample:

var contentString = '<div id="content">'+
'<div id="siteNotice">'+
'</div>'+
'<h1 id="firstHeading" class="firstHeading">Uluru</h1>'+
'<div id="bodyContent">'+
'<p><b>Uluru</b>, also referred to as <b>Ayers Rock</b>, is a large ' +
'sandstone rock formation in the southern part of the '+
'Northern Territory, central Australia. It lies 335&#160;km (208&#160;mi) '+
'south west of the nearest large town, Alice Springs; 450&#160;km '+
'(280&#160;mi) by road. Kata Tjuta and Uluru are the two major '+
'features of the Uluru - Kata Tjuta National Park. Uluru is '+
'sacred to the Pitjantjatjara and Yankunytjatjara, the '+
'Aboriginal people of the area. It has many springs, waterholes, '+
'rock caves and ancient paintings. Uluru is listed as a World '+
'Heritage Site.</p>'+
'<p>Attribution: Uluru, <a href="https://en.wikipedia.org/w/index.php?title=Uluru&oldid=297882194">'+
'https://en.wikipedia.org/w/index.php?title=Uluru</a> '+
'(last visited June 22, 2009).</p>'+
'</div>'+
'</div>';
var infowindow = new google.maps.InfoWindow({
content: contentString
});
Mr.Rebot
  • 6,703
  • 2
  • 16
  • 91