I have some markers on a Google map and would like to make it open a new tab or window when they are clicked on. I only am able to open the clicked marker url in the same browser window tab.
This is how it works now...
var latlon = new google.maps.LatLng(MAP_FOCUS_LATITUDE, MAP_FOCUS_LONGITUDE);
var myOptions = {
center : latlon,
zoom : 14,
mapTypeId : google.maps.MapTypeId.ROADMAP,
mapTypeControl : false,
navigationControlOptions : {
style : google.maps.NavigationControlStyle.LARGE
}
};
var map = new google.maps.Map(document.getElementById("mapholder"), myOptions);
var marker = new google.maps.Marker(
{
position : new google.maps.LatLng(10.0,20.0),
title : "Blah",
url : "http://www.myurltest.com"
});
google.maps.event.addListener(marker, 'click', function() {
window.location.href = this.url;
});
In HTML, normally you can do this to open a link in a new tab... so how do I get this effect ?
<a href="http://www.myurltest.com" target="_blank">Blah blah</a>
I would appreciate any assistance !
The url property it's to define a sprite sheet for style the icon, nevertheless change the callback of click for this
window.open(this.url, '_blank');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With