修改我的Google地图的自定义标记图片大小 [英] Modify my custom marker image size for my Google Map

查看:1230
本文介绍了修改我的Google地图的自定义标记图片大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义图片(512 x 512)如果我使用这个图片,地图不会渲染它,因为它太大了。我必须缩小图像的大小。我想把它做成大约22 x 32,大约是一个图标的大小。我可以使用MS Paint或Paint Shop Pro在桌面上缩小图像,但是当我在地图中打开图像时,它看起来很模糊。一些质量已经下降。


  1. 有没有方法在标记选项中设置尺寸,这样我仍然可以使用原始图像?

  2. 如果没有,有人知道如何缩小图像而不会损失图像质量吗?

我尝试在代码如下,但没有在地图上呈现。



var image = {url:'/Images/orange_guy.png',// image is 512 x 512 size:new google.maps.Size(22,32),}; var marker = new google.maps.Marker({position:{lat:location.Lat,lng:location.Long},map:map,icon:image});

使用 scaledSize 取而代之 size

  var image = {
url: '/Images/orange_guy.png',//图片为512 x 512
scaledSize:new google.maps.Size(22,32)
};

工作小提琴:

http://jsfiddle.net/4mtyu/556/


I have a custom image (512 x 512) If I use this image maps doesn't render it because it's too big. I have to shrink the size of the image down. I want to make it about 22 x 32, which is about the size of an icon. I can shrink the image down on my desktop using MS Paint or Paint Shop Pro, but when I open it in maps it looks blurry. Some of the quality has been degraded.

  1. Is there a way to set the size in the marker options so I can still use the original image?
  2. If not, does anyone know how to shrink an image without loosing quality?'

I tried setting the size in the code below but nothing gets rendered on the map.

var image = {
        url: '/Images/orange_guy.png', // image is 512 x 512
        size: new google.maps.Size(22, 32),     
    }; 

    var marker = new google.maps.Marker({
        position: { lat: location.Lat, lng: location.Long },
        map: map,
        icon: image
    });

解决方案

Use scaledSize instead of size:

var image = {
        url: '/Images/orange_guy.png', // image is 512 x 512
        scaledSize : new google.maps.Size(22, 32)
    };

Working fiddle:

http://jsfiddle.net/4mtyu/556/

这篇关于修改我的Google地图的自定义标记图片大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆