【问题标题】:Angular Google Maps Custom Marker google objectAngular 谷歌地图自定义标记谷歌对象
【发布时间】:2015-12-03 12:32:51
【问题描述】:

我正在使用 Angular Google 地图,我想使用自定义标记。我不希望它成为图像。我想要这样的东西:

icon: {
          path: google.maps.SymbolPath.CIRCLE,
          scale: 12,
          fillColor: '#2677FF',
          fillOpacity: 1,
          strokeColor: '#ffffff',
          strokeOpacity: 1,
          strokeWeight: 6
}

但我收到google is not defined 的错误。我如何获得该对象?

这是我的看法:

<ui-gmap-google-map center='map.center' zoom='map.zoom' pan='true' refresh='true'>

<ui-gmap-marker coords="map.currentPos.coords" options="map.currentPos.options" events="map.currentPos.events" idKey="map.currentPos.id" icon="map.currentPos.icon">
            </ui-gmap-marker>

</ui-gmap-google-map>

这是我的地图:

$scope.map = { 
      center: { latitude: $scope.position.lat, longitude: $scope.position.lng }, 
      zoom: 10, 
      options: { scrollwheel: false, disableDefaultUI: true, draggable: true, scrollwheel: false },
      events: {

      },
      markers: [],
      bounds: {},
      polylines: [],
      currentPos: {
        id: 'currentpos',
        coords: {
          latitude: $scope.position.lat,
          longitude: $scope.position.lng
        },
        options: { draggable: false, clickable: false, zIndex: 1000 },
        events: {

        },
        icon: '',

      },
      control: {
        refresh: function(){
        }
      }
    };

【问题讨论】:

    标签: javascript angularjs google-maps angular-google-maps


    【解决方案1】:

    google.maps.SymbolPath 类示例用法;

    var marker = new google.maps.Marker({
        position: map.getCenter(),
        icon: {
          path: google.maps.SymbolPath.CIRCLE,
          scale: 10
        },
        draggable: true,
        map: map
      });
    

    【讨论】:

      【解决方案2】:

      好的,我找到了方法:

      uiGmapGoogleMapApi.then(function(maps){
            $scope.map.currentPos.icon = {
                path: google.maps.SymbolPath.CIRCLE,
                scale: 12,
                fillColor: '#2677FF',
                fillOpacity: 1,
                strokeColor: '#ffffff',
                strokeOpacity: 1,
                strokeWeight: 6
            }
          });
      

      【讨论】:

        猜你喜欢
        • 2015-10-19
        • 2015-06-06
        • 2013-08-21
        • 1970-01-01
        • 2016-09-20
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多