在地图外部的div中加载Fusion Tables InfoWindow数据 [英] Loading Fusion Tables InfoWindow data in a div outside map

查看:73
本文介绍了在地图外部的div中加载Fusion Tables InfoWindow数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有人可以帮助完成一个可能相当简单的查询.我在这里看到了一个有关在没有鼠标单击的情况下尝试执行此操作的问题,但是我想向Fusion Table地图上的标记添加事件侦听器,以将infoWindow内容加载到地图下方的单独div中.到目前为止,我已经取消了infoWindow的操作,但是在添加点击,检索与该标记相关的数据并将其加载到div的下一步中,我有点迷失了.

I hope someone can help with what is probably a fairly simple query. I have seen a question on here about trying to do this without a mouseclick, but I want to add an event listener to the markers on the Fusion Table map that will load the infoWindow content in a separate div below the map. So far I have suppressed the infoWindow, but I'm a bit lost on the next step of adding the click, retrieving the data relevant to that marker and loading into the div.

标记显示仅限于用户位置的设定半径内的标记,以减少加载时间.

The marker display is limited to markers within a set radius of the user's location, in order to reduce load time.

我假设我需要从这样的东西开始:

I'm assuming I need to start with something like this:

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

如果有任何线索,我将不胜感激.

I'd be grateful for any clues.

这是到目前为止我代码的相关内容:

Here's the relevant bit of my code so far:

var tableid = '[ID]';

var layer = new google.maps.FusionTablesLayer({
query: {
select: 'Location',
from: tableid,
where: 'ST_INTERSECTS(Location, CIRCLE(LATLNG'+marker.position+', 2000))'
},
options: {
suppressInfoWindows: true
}
});

var circle = new google.maps.Circle({
                map: map,
                radius: 2000,
fillOpacity: 0.1,
strokeOpacity: 0,
clickable: false
});

    circle.bindTo('center', marker, 'position');

layer.setMap(map);
    });

为了大家的娱乐,这是我到目前为止尝试过的:

For everyone's amusement, this is what I've tried so far:

google.maps.event.addListener(layer, "click", function () {
            $('#infoWindowDiv').append('new google.maps.infoWindowHtml');
        });

可能没有一个人感到惊讶,这是行不通的.但是,至少我正在尝试!谢谢

It probably comes as a surprise ot no-one that it doesn't work. But hey, at least I'm trying! Thanks

我很高兴地说我找到了一个可行的解决方案-我在这里将其发布给可能有相同问题/目标的其他人:

I'm delighted to say I have found a solution that works - which I post here for anyone else who might have the same problem/goal:

google.maps.event.addListener(layer, "click", function (e) {
            document.getElementById("infoWindowDiv").innerHTML = e.infoWindowHtml;
});

推荐答案

我很高兴地说我找到了一个可行的解决方案-我将其发布在这里,供其他可能遇到相同问题/目标的人使用:

I'm delighted to say I have found a solution that works - which I post here for anyone else who might have the same problem/goal:

 google.maps.event.addListener(layer, "click", function (e) {
        document.getElementById("infoWindowDiv").innerHTML = e.infoWindowHtml;
        });

这篇关于在地图外部的div中加载Fusion Tables InfoWindow数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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