Just recently it was brought to my attention that when you hover over a pushpin in Multimap a tooltip appears. For those who are migrating to Bing Maps V7 you may notice this does not happen but want this functionality. There are two ways to go about this. The first is unsupported and requires accessing undocumented properties of Bing Maps and has so far proven to cause bugs. A second approach uses Bing Maps in a somewhat more supported manner and makes use of jQuery to help it out. The general idea is to first assign each pushpin a unique typeName property. The typeName property can be used to set class names on pushpins. Once each of your pushpins have a unique name you can use jQuery to get each pushpin by typeName and then assign a title property to the image. Here is some sample code that does just this:
<html> <script type=”text/javascript” src=”http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0″></script> function GetMap() // Retrieve the location of the map center |
Nice approach. Certainly cleaner than the alternative hacks I’ve seen (and used) :)
Cool. Do you know if its possible to show a tooltip with polylines also?
Couldnt find a solution because there is no typeName attribute.. Thank you!
For polylines and polygons you will have to use mouse events to create a tooltip effect.
I could show a custom for mouseover and hide it when mouseout. That would be my tooltip.
Do you know a better Solution?
Thanks.
A custom HTML div Element.