Google地图v3:标记尺寸较大

Chu*_*ill 4 google-maps

我需要在地图上显示标记并且它运行良好.唯一的问题是它们看起来太小了.如何确保使用的标记尺寸较大,几乎可以从任何缩放状态中看到?

Jon*_*ran 10

为了使图标更大我肯定会建议你的图标图像更大.例如,使用缩小的高分辨率图标修复高dpi移动设备上的像素图标使用以下代码:

var marker = new google.maps.Marker({
    position: new google.maps.LatLng(position.coords.latitude, position.coords.longitude),
    map: map,
    icon: {
        url: "img/img.png",
        scaledSize: new google.maps.Size(32, 32) // pixels
    }
});

使用Google Maps API JavaScript v3.13进行测试


her*_*ist 7

如果你使用api版本3

创建标记时,您可以在标记选项中指定如下图标:

icon: new google.maps.MarkerImage(
         url:string, size?:Size, 
         origin?:Point, anchor?:Point, scaledSize?:Size
      )
Run Code Online (Sandbox Code Playgroud)

将大小设置为图标图像的实际大小.将scaledSize设置为您要将图像拉伸到的任何大小.

最好将图标图像设置为您想要的尺寸而不是缩放它.