0
我已經嘗試了很多方法來加載我的base64字符串圖像作爲谷歌地圖自定義標記在Chrome中。 此:谷歌地圖自定義標記與base64字符串
var marker = new google.maps.Marker({
position: latLng,
map: map,
title: 'hello',
id: 'the id',
icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAA..."
});
根據建議here,使我的形象,以支付我的800x400px地圖上半部分。
所以我想我不得不重新調整圖像的大小,並做了以下,並沒有圖像顯示。
var my_marker = new Image(30, 30);
$(my_marker).attr('style', 'z-index: 1000')
my_marker.onload = function() {
var marker = new google.maps.Marker({
position: pos,
map: map,
title: pps[0].place_name,
icon: my_marker
});
map.setCenter(pos);
};
my_marker.src = pps[0].place_photo;
儘管當我停止開發人員工具中的代碼時,my_marker對象看起來很不錯,包括z-index。
有關我應該怎麼做才能調整base64圖像的大小並使其顯示爲Google地圖標記的任何想法?這就是問題所在:從原始生成base64時的大小重新調整圖像大小 - 在我的情況下非常大。謝謝
你嘗試過的圖標縮放[google.maps.Icon對象]的屬性(HTTPS:/ /developers.google.com/maps/documentation/javascript/reference#Icon)? [geoxml3第三方KML分析器](https://code.google.com/p/geoxml3/)使用kmz分支中嵌入圖像的數據URL。 – geocodezip
[包含數據URL的base64編碼自定義圖標的小提琴](http://jsfiddle.net/J7mf7/)。 – geocodezip
感謝geocodezip。您的小提琴中的代碼使我的base64圖像顯示在地圖的整個上半部分。它看起來像重新調整是問題。不過謝謝。另外,我不想使用第三方庫。 – pdschuller