Krpano Bing Maps Plugin
- The Bing Maps Plugin adds an interactive Bing Map to the viewer.
- The map can be freely placed and sized anywhere on the screen.
- It’s possible to place spots on the map and link them to krpano actions like loadpano to load a new panoramas when clicking a spot.
- The plugin has an integrated customizable radar which can apear on the activatted spot.
- ‘Google Maps’ styled controls, like the position and zoom controls can be added.
- And it’s possible to control the whole maps and spots dynamically, e.g. pan/zoom around on the map, add or remove spots…
- Google Maps / Bing Maps Notes – the XML interfaces of the Bing Maps and the Google Maps plugins are almost the same. To use the Bing Maps plugin just replace the Google Maps plugin and change the Google Maps key with a Bing Maps key.
Plugin documentation topics:
- Usage Syntax
- Plugin Attributes
- Plugin Subnodes:
- Plugin Actions
Usage Syntax
The Bing Maps Plugin embedding with all attributes / sub-nodes and their default values:
<plugin name="map" url="%VIEWER%/plugins/bingmaps.js" align="leftbottom" width="400" height="300" x="0" y="0" keep="true" key="...your Bing Maps API key..." maptype="satellite" culturecode="" lat="..." lng="..." zoom="1" activespotenabled="false" bgcolor="0x000000" bgalpha="0.0" onmapready="" onmaptypechanged="" onmapmoved="" onmapzoomed="" > <spotstyle name="style1" ... /> ... <spot name="spot1" ... active="true" /> <spot name="spot2" ... /> <spot name="spot3" ... /> ... <radar visible="true" ... /> <maptypecontrol visible="false" ... /> </plugin>
Plugin Attributes
- key
- The Bing Maps API key.
- To be able to use the Bing Maps services a Bing Maps API key is needed!
- Note – a Bing Maps API key is typically not domain limited!
- Sign up here for a Bing Maps API key…
- Multi-Domain-Key-Pairs
- It is possible to use several domain-key pairs as key-attribute to use different keys for different domains.
- Just separate all the domains and keys by pipe | characters.
- To set a key for local testing (file://) there is the special domain name “local” available.
- Syntax / usage example:
key="yourdomain1.com|key1|yourdomain2.com|key2|local|key1"
- maptype
- Select the type of the map:
- satellite (default)
- normal
- hybrid
- Select the type of the map:
- culturecode
- Select a custom language for the map labels.
- For the supported culture codes please see here:
- Note – The culturecode setting need to be set already at startup of the plugin, changing it later is not possible!
- lat / lng
- Latitude and Longitude in degrees.
- The geographic coordinates of the current map center position.
- zoom
- Set zoom level of the map.
- Can be from 1 to 25.
- activespotenabled
- Should the active spot be enabeld?
That means – should the active spot react to click or over events.
- Should the active spot be enabeld?
- bgcolor / bgalpha
- The color and alpha of the map background.
- mapsapi
- Set manually a different url of the Bing Maps API.
- The full url, including the protocol and the API version would need to be set.
- When not set, this default url will be used:
For HTTP:http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0
For HTTPS:
https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0&s=1
Plugin Attributes – Events
- onmapready
- Will be called when the Bing Maps Plugin is loaded and ready for usage.
- onmaptypechanged
- Will be called when the map type was changed.
- onmapmoved
- Will be called when the map was moved.
- onmapzoomed
- Will be called when the map was zoomed.
Plugin Subnodes – <spotstyle>
- With the <spotstyle> subnode it is possible to define styles for the spots.
- A spot can be assigned to a spotstyle by the spotstyle attribute.
- There is a predefined style named “DEFAULT”.
The <spotstyle> node with all settings and their default values:
<spotstyle name="DEFAULT" url="" overurl="" activeurl="" edge="center" x="0" y="0" scale="1.0" />
<spotstyle> Attributes
- name
- url
- The url / path to an image that should be used for the spot.
When not defined the default image (a blue dot) will be used.
- The url / path to an image that should be used for the spot.
- overurl
- The url / path to an image that will be used for the spot when it mouse is over the spot.
When not defined the default image (a blue dot) will be used.
- The url / path to an image that will be used for the spot when it mouse is over the spot.
- activeurl
- The url / path to an image that will be used when the spot is activated.
When not defined the default image (a green dot) will be used.
- The url / path to an image that will be used when the spot is activated.
- edge
- The alignment edge / anchor point of the spot image.
Possible values: lefttop, left, leftbottom, top, center, bottom, righttop, right, rightbottom.
- The alignment edge / anchor point of the spot image.
- x / y
- The offset in pixels from the edge point to the image.
- scale
- Scaling for the spotstyle images.
- Can be used to use higher resolution (2x scaled) images for the iPad 3 retina screen. Use the bigger image and scale=”0.5″ to get a 1:1 display of the image on the iPad 3.
Plugin Subnodes – <spot>
- With the <spot> subnode it is possible to define spots on the map.
- A spot will be placed at lat/lng coordinates and can be linked to panos by using the loadpano / loadscene actions in the onclick event.
The <spot> node with all settings and their default values:
<spot name="..." spotstyle="DEFAULT" url="..." lat="..." lng="..." heading="0" active="false" onover="" onhover="" onout="" onclick="" />
<spot> Attributes
- name
- The name of the current spot (see the xml name notes).
- spotstyle
- The name of the spotstyle that should be used for that spot.
- url
- The url / path to an image that should be used for the spot.
When not defined the image from the spotstyle will be used.
- The url / path to an image that should be used for the spot.
- lat / lng
- Latitude and Longitude in degrees.
- The geographic coordinates of the spot.
- heading
- The heading of the pano in degrees, needed to align the pano orientation with the radar on the map.
- See also the radar headingoffset setting for details.
- active
- State of the spot. When set to true the spot will be activated. That means the spot will show the active spotstyle image (when no url was set) and that the radar will be shown at the spot location.
- To activate a spot dynamically use the activatespot() action.
<spot> Events
- onover
- Actions / functions that will be called when the mouse moves over the spot element.
- Actions / functions that will be called in intervals (several times per second) when the mouse stays over / hovers the spot element.
- Actions / functions that will be called when the mouse moves out of the spot element.
- Actions / functions that will be called when there is a mouse click on the spot element.
<spot> Actions
- activatespot()
- Activate the current spot.
- pantospot()
- Pan the map center to the current spot.
Plugin Subnodes – <radar>
- Add and style a radar.
- The radar will be shown at the active spot position.
The <radar> node with all settings and their default values:
<radar visible="true" dragable="true" size="100" zoomwithmap="false" headingoffset="90" alpha="0.5" fillcolor="0xFFFFFF" fillalpha="1.0" linewidth="0.0" linecolor="0xFFFFFF" linealpha="0.0" />
<radar> Attributes
- visible
- Show or hide the radar.
- dragable
- Should the radar cone be dragable by the mouse?
- size
- The size / range of the radar cone.
- zoomwithmap
- Should the radar cone also be zoomed when zooming the map?
- headingoffset
- An offset for the heading value of the spots.
- The default value for headingoffset is 90, which means heading=0 is pointing to right/east by default. Use headingoffset=0 to let heading=0 pointing to top/north.
- alpha
- The alpha transparency of the whole radar element.
- fillcolor / fillalpha
- The color and alpha of the filling of the radar cone.
- linewidth / linecolor / linealpha
- The linewidth, color and alpha of the line around the radar cone.
Bing Maps Controls
- These Controls are available:
- The Map-Type Control – select the current maptype.
- Note – beside of these included controls it’s possible to use own images as controls by using normal krpano plugin elements and adding them with the parent setting to the map.
All controls with all settings and their default values:
<maptypecontrol visible="true" align="rightbottom" x="2" y="2" buttonalign="H" buttontexts="Map|Satellite|Hybrid" scale="1.0" />
Control Attributes
- visible
- Show or hide the control.
- align
- Alignment of the control.
Possible settings: lefttop, righttop, leftbottom, rightbottom.
- Alignment of the control.
- x / y
- Offset in pixels from the alignment point.
- maptypecontrol.buttonalign
- Alignment of the map type buttons. Possible settings: “H” or “V”.
- maptypecontrol.buttontexts
- The button maptype texts.
- maptypecontrol.scale
- The scaling of the maptype buttons.
- With the default scaling (1.0) the buttons might be too small for easy usage on mobile devices (iPhone, Android phones), so they can be scaled optionally by using this setting and the xml devices setting. For example:
<maptypecontrol visible="true" align="righttop" x="5" y="5" /> <maptypecontrol scale="1.5" buttonalign="V" devices="mobile" />
Plugin Actions
Actions of the Bing Maps Plugin object.
Usage example:
plugin[map].activatespot(spot1); plugin[map].pantospot(spot1);
All actions:
Actions documenation:
- activatespot(name)
- Activate the spot wih the given name.
- That means the spot will show the active spotstyle image (when no url was set) and that the radar will be shown at the spot location.
- addimagespot(name, lat, lng, heading, spotstyle, url, onclick, onhover, onover, onout)
- Add a new spot with a custom image.
- name = name of the new spot.
- lat / lng = the geographic coordinates of the spot.
- heading = pano heading for the spot.
- spotstyle = spotstyle for the spot.
- url = url of the image for the spot.
- onclick, onhover, onover, onout = mouse events for the spot. (optionally)
- addspot(name, lat, lng, heading, active, onclick, onhover, onover, onout)
- addspotstyle(name, url, overurl, activeurl, edge, x, y)
- Add a new spotstyle.
- name = name of the new spotstyle.
- url = url of the default image. (optionally)
- overurl = url of the over image. (optionally)
- activeurl = url of the active image. (optionally)
- edge = alignment edge / anchor point of the spot images. (optionally)
- x / y = pixeloffset from the edge point. (optionally)
- addstylespot(name, lat, lng, heading, spotstyle, active, onclick, onhover, onover, onout)
- Add a new spot with a custom style.
- name = name of the new spot.
- lat / lng = the geographic coordinates of the spot.
- heading = pano heading for the spot.
- spotstyle = spotstyle for the spot.
- active = activate the spot? (optionally)
- onclick, onhover, onover, onout = mouse events for the spot. (optionally)
- panby(dx,dy)
- Pan the map.
- dx / dy = distance in pixels to pan.
- panto(lat,lng)
- Pan to the given coordinates.
- lat / lng = the map coordinates.
- pantospot(name)
- Pan to the coordinates of the given spot.
- name = name of the spot.
- removeallspots()
- Remove all spots from the map.
- removespot(name)
- Remove the given spot.
- name = name of the spot to be removed.
- setcenter(lat,lng)
- Set a new center for the map.
- lat / lng = the map center coordinates.
- setmaptype(maptype)
- Select a new maptype.
- setzoom(zoom)
- Set a new zoom level for the map.
- zoomin(lat, lng, center)
- Zoom in the map by one zoom level.
- Can be used for own controls.
- lat / lng = zoom toward this coordinates. (optionally)
- zoom = set to true to center the map at the lat/lng coordinates. (optionally)
- zoomout(lat, lng)
- Zoom out the map by one zoom level.
- Can be used for own controls.
- lat / lng = zoom toward this coordinates. (optionally)
- zoomtospotsextent()
- Zoom and pan the map automatically to show all spots.