javascript-来自sprite和视网膜证明的自定义google maps标记

我了解到,当我想将精灵用作Google Map标记时,需要这样输入:

var myIcon = new google.maps.MarkerImage(
    "../public/img/categories.png",
    new google.maps.Size(90, 50),
    new google.maps.Point(0, data[i].subcategory_id * 50)
);

// as I understand: 
// new google.maps.MarkerImage(url, original size, anchor point);

当使它防视网膜时,我知道我需要像这样:

//new google.maps.MarkerImage(url, original size, anchor point, null, half size);
var myIcon = new google.maps.MarkerImage(
    "../public/img/categories.png",
    new google.maps.Size(90,50),
    new google.maps.Point(0, data[i].subcategory_id * 50),
    null,
    new google.maps.Size(45,25)
);

但是,当添加额外的尺寸时,我的标记不再存在.
我究竟做错了什么?

解决方法:

就像@duncan所说的,我需要使用icon类.

var myIcon {
  url: "../public/img/categories.png",
  size: new google.maps.Size(45,25), // the size it should be on the map
  scaledSize: new google.maps.Size(45,550), // the normal size of the image is 90x1100 because Retina asks double size.
  origin: new google.maps.Point(0, 25) // position in the sprite                   
};

这帮助了我,谢谢!

上一篇:javascript – SVG渲染到视网膜显示屏上模糊的画布


下一篇:C# winform写入和读取TXT文件