顯然我已經混淆了V7的V8文檔。不支持實際調整圖釘圖像的大小。
如果你希望能夠縮放圖釘的大小,你將需要使用HTML5的畫布來渲染圖像的縮放版本
你可以找到在這裏的代碼示例: https://social.msdn.microsoft.com/Forums/en-US/909162ea-3ac5-4960-82ed-6ddf02eb6ead/alter-size-of-custom-pushpin-isnt-working?forum=bingmaps
下面是鏈接採取上述代碼:
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<script type='text/javascript'
src='http://www.bing.com/api/maps/mapcontrol?callback=GetMap'
async defer></script>
<script type='text/javascript'>
function GetMap() {
var map = new Microsoft.Maps.Map('#myMap', {
credentials: 'Your Bing Maps Key'
});
createScaledPushpin(map.getCenter(), 'images/myPushpinIcon.png', 2, function (pin) {
map.entities.push(pin);
});
}
function createScaledPushpin(location, imgUrl, scale, callback) {
var img = new Image();
img.onload = function() {
var c = document.createElement('canvas');
c.width = img.width * scale;
c.height = img.height * scale;
var context = c.getContext('2d');
//Draw scaled image
context.drawImage(img, 0, 0, c.width, c.height);
var pin = new Microsoft.Maps.Pushpin(location, {
//Generate a base64 image URL from the canvas.
icon: c.toDataURL(),
//Anchor based on the center of the image.
anchor: new Microsoft.Maps.Point(c.width/2, c.height/2)
});
if (callback) {
callback(pin);
}
};
img.src = imgUrl;
}
</script>
</head>
<body>
<div id="myMap" style=";width:600px;height:400px;"></div>
</body>
</html>
在v8中無法使用 –