none
Infobox shows same data RRS feed

  • Question

  • I have an asp.net website that displays location of vehicles. I have an infobox for each location that shows vehicle info. When the map displays all the infoboxes ({visible: true}) the unique data is there for each vehicle. I have a mouse over event to show infobox and a viewchange to hide the infobox. When I mousover any pushpin, the same info shows up regardless of the pushpin. Can't figure out why the same data shows up no matter what pushpin I mouseover. Here is the code:

    To create pushpins and infoboxes:

                locations += "var pushpin = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(" & reader("Latitude").ToString() & _
                    ", " & reader("Longitude").ToString() & "),null);" & _
                    "pinInfobox = new Microsoft.Maps.Infobox(new Microsoft.Maps.Location(" & reader("Latitude").ToString() & _
                    ", " & reader("Longitude").ToString() & "), " & _
                    "{title: 'My Pushpin', description: '" & reader("vehicle_number") & ": " & reader("dn") & _
                    " - " & reader("drivername") & "',visible: false});" & _
                    "Microsoft.Maps.Events.addHandler(pushpin, 'click', ZoomIn);" & _
                    "Microsoft.Maps.Events.addHandler(pushpin, 'mouseover', displayInfobox);" & _
                    "Microsoft.Maps.Events.addHandler(map, 'viewchange', hideInfobox);" & _
                    "map.entities.push(pushpin);" & _
                    "map.entities.push(pinInfobox);"

    Events:

      Me.Literal1.Text = "<script type='text/javascript' src='http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0'></script>" & _
                "<script type='text/javascript'>var  map = new Microsoft.Maps.Map(document.getElementById('myMap'), " & _
                "{credentials:  'my bing map key'});" & _
                "function GetMap() " & _
                "{ " & _
                "map.entities.clear(); " + Locations + " function ZoomIn(e)" & _
                    "{if (e.targetType == 'pushpin')" & _
                        "{var location = e.target.getLocation();" & _
                            "map.setView({zoom:5,center: location});" & _
                         "}" & _
                     "}" & _
                "}" & _
                "function displayInfobox(e) { pinInfobox.setOptions({ visible:true });};" & _
                "function hideInfobox(e){pinInfobox.setOptions({ visible: false });}" & _
               "</script>"

    Appreciate the help.

    Thursday, August 13, 2015 11:33 AM

Answers

All replies