admin管理员组

文章数量:1315345

Can someone show me how to custom the pin for Bing maps, version 7.0 please? I'm experimenting with upgrading from version 6 which has a custom icon but I cant find anywhere that shows how to do this with version 7. I have the following code so far.

Many thanks,

var map = null; 
var pinInfobox = null;

function GetMap()
{
    map = new Microsoft.Maps.Map(document.getElementById("myMap"), {
    credentials: "xxx",
    height: 236,
    width: 269,
    enableClickableLogo: false,
    enableSearchLogo: false,
    mapTypeId: Microsoft.Maps.MapTypeId.road,
    showDashboard: false});


    var loc = new Microsoft.Maps.Location(47.592, -122.332);
    var pin = new Microsoft.Maps.Pushpin(loc);
    map.entities.push(pin);
    map.setView({ center: loc, zoom: 6 });
}

Can someone show me how to custom the pin for Bing maps, version 7.0 please? I'm experimenting with upgrading from version 6 which has a custom icon but I cant find anywhere that shows how to do this with version 7. I have the following code so far.

Many thanks,

var map = null; 
var pinInfobox = null;

function GetMap()
{
    map = new Microsoft.Maps.Map(document.getElementById("myMap"), {
    credentials: "xxx",
    height: 236,
    width: 269,
    enableClickableLogo: false,
    enableSearchLogo: false,
    mapTypeId: Microsoft.Maps.MapTypeId.road,
    showDashboard: false});


    var loc = new Microsoft.Maps.Location(47.592, -122.332);
    var pin = new Microsoft.Maps.Pushpin(loc);
    map.entities.push(pin);
    map.setView({ center: loc, zoom: 6 });
}
Share Improve this question edited Dec 10, 2013 at 7:37 Kara 6,22616 gold badges53 silver badges58 bronze badges asked May 25, 2011 at 11:40 James RadfordJames Radford 4234 gold badges7 silver badges13 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

check out the reference documentation which has an "icon" option to set a custom icon

http://msdn.microsoft./en-us/library/gg427629.aspx

There is a really good site that documents how to do this exact operation.

http://www.bingmapsportal./isdk/ajaxv7#Pushpins2

Here is the JavaScript from that site that says how to do it:

map.entities.clear(); 
var pushpinOptions = {icon: virtualPath + '/Content/SpaceNeedle.jpg', width: 30, height: 50}; 
var pushpin= new Microsoft.Maps.Pushpin(map.getCenter(), pushpinOptions);
map.entities.push(pushpin);

本文标签: javascripthow to create a custom pin on Bing maps v7Stack Overflow