【问题标题】:Google Map API v3 multiple marker with labels/text [duplicate]带有标签/文本的 Google Map API v3 多标记 [重复]
【发布时间】:2014-08-20 06:48:24
【问题描述】:

我找到了在谷歌地图标记上放置标签/文本的解决方案。可在此链接中找到http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerwithlabel/1.1.8/docs/reference.html

我的问题是标记放在一个地方。但是每个标记上的标签/文本都放置在正确的点上。谁能帮帮我?

下面的代码在一个用于循环的 $.each() jQuery 函数中。

geocoder.geocode( { 'address': address }, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
        var contentString = "sample text";

        var infowindow = new google.maps.InfoWindow({
            content: contentString;
        });

        var marker = new MarkerWithLabel({
            position: results[0].geometry.location,
            map: map,
            animation: google.maps.Animation.DROP,
            title: address,
            labelContent: lblAddress,
            labelAnchor: new google.maps.Point(7, 30),
            labelClass: "map-labels", // the CSS class for the marker
        });

        google.maps.event.addListener(marker, 'click', function() {
            infowindow.open(map, this);
        });
}

上图显示两个不同点的标记显示在一个位置。我很确定,因为当我单击标签“18107 Gold Mesa”时,会打开一个信息窗口,但该信息窗口将显示在“3611 Alonzo Fields”上。该点上有两个标记。

但是当我不使用 3rd 方库时。标记放置在正确的点上。使用谷歌地图方法放置标记。 new google.maps.Marker

谢谢, 贾斯汀

【问题讨论】:

    标签: javascript google-maps google-maps-api-3 google-maps-markers


    【解决方案1】:

    使用 infowindow.open(map, marker);

    而不是

    infowindow.open(地图, 这个);

    我想这只会在标签附近显示您的弹出窗口,您可能会发现标记未显示的一些重要原因

    【讨论】:

    • 它不能解决我的问题。
    猜你喜欢
    • 2012-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-29
    • 2012-05-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多