Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google maps api 3 谷歌地图自定义标记图标配置从精灵表与视网膜支持_Google Maps Api 3 - Fatal编程技术网

Google maps api 3 谷歌地图自定义标记图标配置从精灵表与视网膜支持

Google maps api 3 谷歌地图自定义标记图标配置从精灵表与视网膜支持,google-maps-api-3,Google Maps Api 3,我的谷歌地图使用从精灵表加载的自定义标记pin,在1x、2x和3x显示时一切正常,除了@2x,@3x图像显示为原始图像大小的三倍 如果我尝试在@2x和@3x显示时将其缩放回1x尺寸,则标记将显示,而不显示图像 谷歌搜索表明我做的一切都是对的,图标配置是基于文档的 有人能发现我的scaleImage配置有什么问题吗 if(devicePixelRatio > 1) { pinImage['scaledSize'] = new google.maps.Size(15, 36); } 从J

我的谷歌地图使用从精灵表加载的自定义标记pin,在1x、2x和3x显示时一切正常,除了@2x,@3x图像显示为原始图像大小的三倍

如果我尝试在@2x和@3x显示时将其缩放回1x尺寸,则标记将显示,而不显示图像

谷歌搜索表明我做的一切都是对的,图标配置是基于文档的

有人能发现我的
scaleImage
配置有什么问题吗

if(devicePixelRatio > 1) {
  pinImage['scaledSize'] = new google.maps.Size(15, 36);
}
从JavaScript中提取代码:

var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);

// Retina support
var requireImagePrefix = "";
var devicePixelRatio = (window.devicePixelRatio===undefined?1:window.devicePixelRatio);

if(devicePixelRatio == 2) {
  requireImagePrefix = "@2x";
}
else if(devicePixelRatio == 3) {
  requireImagePrefix = "@3x";
}

// Image for the marker
var pinImage = {
  url: "/assets/sprite" + requireImagePrefix + ".png",
  size: new google.maps.Size(15*devicePixelRatio, 36*devicePixelRatio),
  origin: new google.maps.Point(430*devicePixelRatio, 20*devicePixelRatio),
};

if(devicePixelRatio > 1) {
  pinImage['scaledSize'] = new google.maps.Size(15, 36);
}

var officeMarker = new google.maps.Marker({
  position: hqLocation,
  map: map,
  title: "Anomaly HQ",
  icon: pinImage,
  optimized: false
});

非常感谢您的时间。

我在上面的错误是:

  • scaledSize
    参数是1x精灵的尺寸
  • 我们不需要将
    size
    origin
    参数乘以纵横比
我已经发布了更新的解决方案作为一个Git哦