【问题标题】:gmap3 How to do it - any event it shows circlegmap3 怎么做 - 它显示圆圈的任何事件
【发布时间】:2015-04-08 11:32:52
【问题描述】:

作为主题,在例如之后如何做到这一点。单击标记出现在以标记参数为中心的圆圈中?

如何获得:latLng(这个标记)。

请帮忙

代码:

函数映射(){

var x1 = [37.772323, -122.214897];
var x2 = [37.752323, -122.214897];

$('#mapFull').gmap3({
    map: {
        options: {
            center: [37.772323, -122.214897],
            zoom: 12,
            mapTypeControlOptions: {
                mapTypeIds: ['custom_style', google.maps.MapTypeId.SATELLITE, google.maps.MapTypeId.HYBRID]
            }
        }
    },
    marker: {
        values: [{
                latLng: [x1[0], x1[1]],
                data: 'x1'
            }, {
                latLng: [x2[0], x2[1]],
                data: 'x2'
            }
        ],
        events: {
            click: function (marker, event, context) {
                var map = $(this).gmap3("get"),
                        infowindow = $(this).gmap3({get: {name: "infowindow"}});
                if (infowindow) {
                    infowindow.open(map, marker);
                    infowindow.setContent(context.data);
                } else {
                    $(this).gmap3({
                        infowindow: {
                            anchor: marker,
                            options: {content: context.data},
                            circle: {
                                center: [37.772323, -122.214897],
                                radius: 250,
                                fillColor: "#008BB2",
                                strokeColor: "#005BB7"
                            }
                        }
                    });
                }
            }
        }
    }
});

}

【问题讨论】:

  • 你能给我们一些代码吗? gmap3 初始化?

标签: javascript events click geometry jquery-gmap3


【解决方案1】:

您可以使用以下代码添加一个以单击标记为中心的圆圈:

$('#mapFull').gmap3({
    map: {
        ...
    },
    marker: {
        values: [...],
        events: {
            click: function (marker, event, context) {
                ...
                $(this).gmap3({
                    circle:{
                        options:{
                            center: [ marker.getPosition().lat(), marker.getPosition().lng()],
                            radius : 250,
                            fillColor : "#008BB2",
                            strokeColor : "#005BB7"
                        }
                    }
                });
            }
        }
    }
});

【讨论】:

  • 干得好,我只是不知道怎么去:marker.getPosition().lat(), marker.getPosition().lng() 谢谢;-)
猜你喜欢
  • 1970-01-01
  • 2022-08-19
  • 1970-01-01
  • 2018-06-17
  • 2017-01-06
  • 2017-04-26
  • 1970-01-01
  • 1970-01-01
  • 2017-02-18
相关资源
最近更新 更多