将HTML链接添加到Google地图圈元素 [英] Add HTML Link to Google Maps Circle Element

查看:124
本文介绍了将HTML链接添加到Google地图圈元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确信有一个简单的方法可以做到这一点,但我似乎无法在Google地图在线文档中找到它。我有一个圈子的地图,这个想法是,点击该圈子将打开一个新的HTML页面。

I am sure there is a simple way to do this, but I can't seem to find it within the Google Maps online documentation. I have a map with several circles and the idea is that clicking on the circle will open up a new HTML page.

对于每个圈子.....

For each circle.....

Lat Long定义:

Lat Long is defined:

var NZNorth=new google.maps.LatLng( -38.929764,176.009002);

圆形变量:

Circle Variables:

var Circle1 = new google.maps.Circle({
center:NZNorth,
 radius:250000,
 strokeColor:"#FA0014",
 strokeOpacity:1,
 strokeWeight:1,
 fillColor:"#FA0014",
 fillOpacity:0.2
 });

调用Circle:

Circle1.setMap(map); 

所以要添加一个超链接onclick圈子,我需要做什么?我不确定是否需要为每个圆圈声明链接,然后在每个圆圈变量中包含一个onclick函数?

So to add a hyperlink onclick of the circle what do I need to do? I am not sure if I have to declare the link for each circle and then include an onclick function in each circle variable?

一如既往感谢您的帮助!

As always thanks for your help!

推荐答案

任何人都有同样的问题,请将网址添加到您的变量中

Incase anyone has the same problem, add the URL to your variable

var Circle1 = new google.maps.Circle({
center:NZNorth,
radius:250000,
strokeColor:"#FA0014",
strokeOpacity:1,
strokeWeight:1,
fillColor:"#FA0014",
fillOpacity:0.2,
URL:'http://www.bbc.co.uk'
});

然后添加侦听器!

google.maps.event.addListener(Circle1, 'click', function() {

 window.location = Circle1.URL; 

});

这篇关于将HTML链接添加到Google地图圈元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆