【问题标题】:custom shape for markers using angular google maps使用角度谷歌地图的标记的自定义形状
【发布时间】:2015-11-16 20:24:13
【问题描述】:

我正在尝试在我的应用程序中使用 angular google maps(http://angular-ui.github.io/angular-google-maps/) 指令,因此将我的代码转换为使用该指令并在该过程中坚持以将自定义形状应用于标记。

任何熟悉 angular google maps 的人都可以帮我解决这个问题,请检查下面提到的用普通 google maps 库编写的代码,并告诉我如何使该代码与 angular google maps 指令一起使用。

new google.maps.Marker({
  position: latLng,
  map: map,
  icon: {
    url: 'path/to/icon',
    origin:new google.maps.Point(0,0),
    anchor:new google.maps.Point(3,4)
  },
  shape: {
    coords:[0, 6, 7, 0, 16, 0, 23, 6, 12, 12],
    type:"poly"
  }
});

【问题讨论】:

    标签: angularjs google-maps google-maps-api-3 angular-google-maps


    【解决方案1】:

    是的,我在这里找到了解决方案,我们需要将其设置为 OPTIONS 对象的属性,如下所述:

                    markers.push({
                        latitude: site.latitude,
                        longitude: site.longitude,
                        id: 1,
                        icon: {
                            url: 'path/to/icon',
                            origin: origin,
                            anchor: anchor
                        },
                        options: {
                            shape: {
                                coords: phaseMarker.coords,
                                type: "poly"
                            }
                        }
                    });
    

    注意:我什至在发布这个问题之前就尝试过了,但是由于标记的 ID 属性重复,所以效果不佳,所以如果我们有一个标记,请确保我们有每个标记的唯一 ID我们地图中的一组标记。

    【讨论】:

      猜你喜欢
      • 2017-12-18
      • 2016-01-16
      • 1970-01-01
      • 2013-08-21
      • 1970-01-01
      • 2014-10-11
      • 2018-11-15
      相关资源
      最近更新 更多