Google Maps API(v3):使用 geoRSS 作为标记源时创建后访问标记

发布于 2024-10-06 04:30:59 字数 915 浏览 0 评论 0原文

我想要一组与地图上的标记相对应的链接,单击这些链接时,会将地图置于相关标记的中心并打开该标记的详细信息。

问题是,当标记来自外部源(KML/geoRSS)时,我无法弄清楚如何访问 Google 地图中的标记。当您没有直接使用 JavaScript 构建地图(而是使用 google.maps.KmlLayer 和 setMap())时,这是否可以做到?

如果可能的话,我不想自己解析 xml。我只需要能够在创建标记后访问它们。其他一切都运行良好。

这是我正在使用的脚本:

;(function($){
    function initialize() {
        var myLatlng = new google.maps.LatLng(49.496675,-102.65625);
        var myOptions = {
            zoom: 4,
            center: myLatlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        }

        map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

        georssLayer = new google.maps.KmlLayer('http://localhost/geoFeed.xml');
        georssLayer.setMap(map);
    }

    $(function(){
        initialize();
    });
})(jQuery);

是否有我在某处没有看到的任何类型的 getMarkers() 函数?我一直在尝试寻找任何类型的方法,甚至深入研究我的地图对象以找出标记信息是否/存储在何处,但找不到任何可以满足我需要的东西。

I want to have a set of links that correspond with the markers on a map that when clicked, center the map on the relevant marker and open the details to that marker.

Problem is I can't figure out how to get access to the markers in a Google map when the markers came from an external source (KML/geoRSS). Is this even possible to do when you didn't directly use JavaScript to build the map (but used a google.maps.KmlLayer with setMap())?

I don't want to have to parse the xml myself if at all possible. I just need to be able to access the markers after they have been created. Everything else is working perfectly.

Here's the script I'm using:

;(function($){
    function initialize() {
        var myLatlng = new google.maps.LatLng(49.496675,-102.65625);
        var myOptions = {
            zoom: 4,
            center: myLatlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        }

        map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

        georssLayer = new google.maps.KmlLayer('http://localhost/geoFeed.xml');
        georssLayer.setMap(map);
    }

    $(function(){
        initialize();
    });
})(jQuery);

Is there any kind of getMarkers() function that I'm just not seeing somewhere? I've been trying to hunt down any kind of method or even digging into my map object to find out if/where the markers information is stored but can't find anything that will get me what I need.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

妥活 2024-10-13 04:30:59

这对于当前的 API 来说是不可能的。

This is not possible with the current API.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文