James Radford
James Radford

Reputation: 423

how to create a custom pin on Bing maps v7

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 });
}

Upvotes: 2

Views: 13703

Answers (2)

Paul Mendoza
Paul Mendoza

Reputation: 5787

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

http://www.bingmapsportal.com/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);

Upvotes: 2

Gingemonster
Gingemonster

Reputation: 927

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

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

Upvotes: 3

Related Questions