javascript - 如何让谷歌标记 url 在新的浏览器窗口或标签中打开?

标签 javascript jquery google-maps google-maps-api-3

我在谷歌地图上有一些标记,我想在点击它们时打开一个新的标签页或窗口。我只能在同一浏览器窗口选项卡中打开单击的标记 url。

这就是它现在的工作方式......

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;
});

在 HTML 中,通常您可以这样做以在新选项卡中打开链接...那么我如何获得这种效果呢?

<a href="http://www.myurltest.com" target="_blank">Blah blah</a>

如有任何帮助,我将不胜感激!

最佳答案

url属性是定义一个sprite sheet来给图标设置样式,但是要改变点击回调

window.open(this.url, '_blank');

关于javascript - 如何让谷歌标记 url 在新的浏览器窗口或标签中打开?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21555278/

相关文章:

Android Phonegap 错误 : google is not defined

javascript - 在jsp中将值从servlet传递到javascript

javascript - 无法读取未定义的属性 'apply '

javascript - 当输入仍然集中时,jquery 代码不执行

javascript - 我想在 JavaScript 中更改日期对象的时区

jQuery catch 动画完成时

google-maps - 谷歌地图缩放级别

javascript - 提交折叠 div 并更改 div 中的图像后的 Ajax 表单

javascript - 将每个表列保存在一个变量中

javascript - ASP : Dynamically update a Google Maps engine instance with new coordinates