1

I have some problems with opening a link in ArcGIS API. I have my popup window where LAT, LONG and LINK are shown.

function addPoint(evt) {
        var latitude = evt.mapPoint.getLatitude();
        var longitude = evt.mapPoint.getLongitude();
        var link = "<a href='http://www.google.com'>Google</a>";
        map.infoWindow.setTitle("Coordinates");
        map.infoWindow.setContent(
        "lat: " + latitude.toFixed(7) + "<br> lon: " + longitude.toFixed(7) + "<br> Room: " + link
        );
        map.infoWindow.show(evt.mapPoint, map.getInfoWindowAnchor(evt.screenPoint));

}

Here is the image example However when I click on the link nothing happens (no redirection or opening in new window). I tried to add window.open() to open the link,

var link = "<a href='http://www.google.com'>Google Office</a>";
        on(link, 'click', openLink);
        function openLink(){
            window.open("http://www.google.com");
        }

but then I get the error message

Uncaught Error: Target must be an event emitter

1 Answer 1

1

i couldn't reproduce the behavior you describe in my own application (see example here), but i did see problems in a jsbin until i added target='_blank' to force the new page to open in a new tab so maybe you're running into something similar in your own application.

"<a target='_blank' href='http://www.esri.com'>link</a>"

(working jsbin example here)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.