【问题标题】:Resize Google Map Marker调整谷歌地图标记的大小
【发布时间】:2015-06-11 04:53:07
【问题描述】:

我想在我的谷歌地图 API 上添加自定义的谷歌地图图钉。我的图像是 135 像素(宽)x 185 像素(高),我想让它更小,例如 26 像素(宽)x 35 像素(高)以看起来适合 googlemap。除了使用工具(ps/ai)调整图像大小之外,这是否可以使图钉看起来更小? 如何添加 scaledSize?

var map = { 
    control: {},
    center: {
        latitude: xxx,
        longitude: yyy

    },
    zoom: 17,
    options: {
        mapTypeControl: mapTypeControl,
        mapTypeControlOptions: {
            style: 1, // GoogleMapApi.maps.MapTypeControlStyle.HORIZONTAL_BAR
            position: 1, // GoogleMapApi.maps.ControlPosition.TOP_LEFT
        },
        streetViewControl: false,
        zoomControl: zoomControl,
        zoomControlOptions: {
            style: 0, // google.maps.ZoomControlStyle.DEFAULT,
            position: 5, // google.maps.ControlPosition.LEFT_CENTER
        },
        scrollwheel: true,
        panControl: false,
        scaleControl: false,
        draggable: true,
        maxZoom: 20,
        minZoom: 15,
    },
    trigger: false,
    bounds: {},
    dragging: false,
    events: { 
        dragend: function() {

        },
        click: function(map, eventName, args) {

        },
        idle: function() {

        }
    },
    rebuildWindows: false,
    templateUrl: 'templates/infowindow.html'
};

谢谢。

【问题讨论】:

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


【解决方案1】:

如果您想用作标记的图像太大,第一个(但显而易见的)建议应该是更改图像的大小以满足您的需要。

但是,您可以通过编程方式进行:

var customPin = new google.maps.MarkerImage("../path-of-you-pin/myPin.png"),
    new google.maps.Size(21, 34),
    new google.maps.Point(0, 0),
    new google.maps.Point(10, 34));
// or use the size you want, this are the default sizes

并像这样使用它:

var marker = new google.maps.Marker({
   // ...
   icon: customPin,
   // ...
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-25
    • 1970-01-01
    • 2016-02-25
    • 1970-01-01
    • 2019-04-27
    • 2011-11-05
    相关资源
    最近更新 更多