PushpinOptions Object
Represents the options for a pushpin.
Properties
| Name | Type | Description |
|---|---|---|
|
anchor |
The point on the pushpin icon which is anchored to the pushpin location. An anchor of (0,0) is the top left corner of the icon. The default anchor is the bottom center of the icon. |
|
|
draggable |
boolean |
A boolean indicating whether the pushpin can be dragged to a new position with the mouse. |
|
height |
number |
The height of the pushpin, which is the height of the pushpin icon. The default value is 39. |
|
htmlContent |
string |
The HTML that represents the pushpin. |
|
icon |
string |
The path of the image to use as the pushpin icon. |
|
infobox |
The info box associated with this pushpin. If the Microsoft.Maps.Themes.BingTheme module is loaded, then the info box appears when the hover or click events of the pushpin occur. |
|
|
state |
The state of the pushpin, such as highlighted or selected. To get the latest pushpin state design, load the Microsoft.Maps.Themes.BingTheme module before creating the pushpin. |
|
|
text |
string |
The text associated with the pushpin. |
|
textOffset |
The amount the text is shifted from the pushpin icon. The default value is (0,5). |
|
|
typeName |
string |
The type of the pushpin, as a string. The pushpin DOM (document object model) node created for the pushpin will have the specified typeName. A standard pushpin type is used unless the Microsoft.Maps.Themes.BingTheme module is loaded, in which case typeName can be set to ‘micro’ to use the micro pushpin type. |
|
visible |
boolean |
A boolean indicating whether to show or hide the pushpin. The default value is true. A value of false indicates that the pushpin is hidden, although it is still an entity on the map. |
|
width |
number |
The width of the pushpin, which is the width of the pushpin icon. The default value is 25. |
|
zIndex |
number |
The z-index of the pushpin with respect to other items on the map. |
Example
This example uses the image below, named “BluePushpin.png”, as the pushpin icon.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>
<script type="text/javascript">
var map = null;
function GetMap()
{
// Initialize the map
map = new Microsoft.Maps.Map(document.getElementById("myMap"),
{credentials:"Bing Maps Key"});
// Retrieve the location of the map center
var center = map.getCenter();
// Add a pin to the center of the map
var pin = new Microsoft.Maps.Pushpin(center, {icon:"BluePushpin.png", height:50, width:50, anchor:new
Microsoft.Maps.Point(0,50), draggable: true});
map.entities.push(pin);
}
</script>
</head>
<body onload="GetMap();">
<div id='myMap' style="position:relative; width:400px; height:400px;"></div>
</body>
</html>