none
Bing Maps not showing InfoBoxes, Error in veapidelay.js RRS feed

  • Question

  • We are using the Bing Maps v7 APIs to publish a map with pushpoints and infoboxes.  Everything was working well until last night(4/19/2012).  Now when the user mouse overs a pushpin we get a script error in the veapidelay.js file that says c.getShouldFireEvents is not defined.  

    Here is the code that we use to insert into the entity collection 

    function LoadPoints(title, description, coordinates, link) {
        try {
            RemoveMapEntities();
            HideHotSpots();

            var latLongPoints = GetCoordinatesFromString(coordinates);

            if (latLongPoints.length > 0) {
                var layer = new Microsoft.Maps.EntityCollection();
                for (var i = 0; i < latLongPoints.length; i++) {
                    var point = new Microsoft.Maps.Pushpin(latLongPoints[i], {});
                    layer.push(point);
                }

                if (title != null && title != "") {
                    var infoboxIndex = GetInfoxboxLocationIndex(latLongPoints);
                    currentInfoboxLocation = latLongPoints[infoboxIndex];
                    var infobox = new Microsoft.Maps.Infobox(currentInfoboxLocation, { title: title, description: description, visible: true, offset: new Microsoft.Maps.Point(0, 30), height: 150 });

                    if (description != null && description != "") {
                        infobox.setOptions({ description: description });
                    }

                    if (link != null && link != "") {
                        infobox.setOptions({ actions: [{ label: projectLinkText, eventHandler: InfoboxLinkClick}] });
                    }

                    Microsoft.Maps.Events.addHandler(infobox, "entitychanged", InfoboxChanged);
                    layer.push(infobox);
                }
           
                map.entities.insert(layer, 3);
              
            }
        }
        catch (err) {
           // alert("An error occurred while loading pushpins.");
        }
    }

    Any thoughts/ideas on how to solve this error?

    Thanks

    Saturday, April 21, 2012 12:42 AM

Answers

  • There was no change around the time you started seeing this issue. Verify that you are passing in real coordinates into the pushpin. i.e. ensure the latitude and longitude coordinates are floats and not strings (common issue for many users when loading in data from external sources).

    http://rbrundritt.wordpress.com

    Monday, May 28, 2012 9:09 AM

All replies

  • There was no change around the time you started seeing this issue. Verify that you are passing in real coordinates into the pushpin. i.e. ensure the latitude and longitude coordinates are floats and not strings (common issue for many users when loading in data from external sources).

    http://rbrundritt.wordpress.com

    Monday, May 28, 2012 9:09 AM
  • I have tracked down the issue.  We were referencing the coreapi.js directly in our HTML page.  Once we shifted it to refer to the 

    "http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"  instead of the coreapi.js the solution started working again

    Friday, June 15, 2012 5:01 PM
  • Hi Ricky,

    I am also facing the problem that was specified above. Infobox is not displayed every time the user clicks on the push pin. We are referring to "http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0" in our cshtml page. I have checked if latitude and longitude values are null, We dont store null values in our application for latitude and longitude.

    I need to show the location of a vehicle in the specified date range in bing maps. We are getting the values from DB as JSON objects in the UI. and plotting the pushpins accordingly. I have declared only on infobox object in the code and am displaying the infobox based on the puspin that is clicked. It seems to be working fine in most of the cases. But intermittently it is observed that the infobox is not shown even if the pushpin has proper lat and lon values. If I refresh the page again it seems to be working.

    Please find the javascript code below. Any help would be appreciated.

    We have declared the variables a global in the js file as they are used from other functions as well.

    var pinInfoBoxTrace;
    var pinLayer = new Microsoft.Maps.EntityCollection();
    var infoboxLayer = new Microsoft.Maps.EntityCollection();
    var tracemap = null;

    function BingMapArrayPP(arrItems) {
        pinLayer.clear();
        infoboxLayer.clear();

        if (arrItems != null && arrItems.length > 0) {
            tracemap = new Microsoft.Maps.Map($("#tracemap")[0],
                   {
                       credentials: BingMapKey,
                       mapTypeId: Microsoft.Maps.MapTypeId.road,
                       center: new Microsoft.Maps.Location(arrItems[0].Latitude, arrItems[0].Longitude),
                       zoom: 10,
                       showMapTypeSelector: true
                   });
            tracemap.entities.clear();
            var center = tracemap.getCenter();
            var pushpinOptions = { icon: '/Images/bingcenterSelected_icon.png', height: 50, width: 50 };

            
            var pin = new Microsoft.Maps.Pushpin(center, pushpinOptions);
            pin.Title = "Title"
            pin.Description = "Description logic from arritem";

           Microsoft.Maps.Events.addHandler(pin, 'click', displayInfoboxNew);
           
            for (var i = 1 ; i < arrItems.length; i++) {
                var latLon = new Microsoft.Maps.Location(arrItems[i].Latitude, arrItems[i].Longitude);

                var pin1 = new Microsoft.Maps.Pushpin(latLon, null); 
                pin1.Title = "Title"
                pin1.Description = '"Description logic from arritem";

                Microsoft.Maps.Events.addHandler(pin1, 'click', displayInfoboxNew);

                pinLayer.push(pin1); //add pushpin to pinLayer
            }
            pinLayer.push(pin);

            tracemap.entities.push(pinLayer);
            tracemap.entities.push(infoboxLayer);
        }
    }

    function displayInfoboxNew(e) {
        
        if (e.targetType == 'pushpin') {

            if (pinInfoBoxTrace != null) {
                infoboxLayer.remove(pinInfoBoxTrace);
                pinInfoBoxTrace = null;
            }
            pinInfoBoxTrace = new Microsoft.Maps.Infobox(null, null);
            pinInfoBoxTrace.setLocation(e.target.getLocation());
            pinInfoBoxTrace.setOptions({ showPointer: true, title: e.target.Title, description: e.target.Description, visible: true, offset: new Microsoft.Maps.Point(0, 20) });
            infoboxLayer.push(pinInfoBoxTrace);
            
        }

    Monday, March 3, 2014 12:59 PM
  • Hi Ricky,

    I would like to provide some additional info in case it helps.

    Sometimes the code is breaking at veapicore.js at removehandler method.

    Regards,

    Murthy

    Monday, March 3, 2014 2:15 PM
  • Take a look at this blog post for a cleaner method for using Infoboxes with pushpins: http://rbrundritt.wordpress.com/2011/10/13/multiple-pushpins-and-infoboxes-in-bing-maps-v7/

    http://rbrundritt.wordpress.com

    Monday, March 3, 2014 2:48 PM
  • Hi Ricky,

    I have gone through the blog before posting here. In my application I have a vehicles list in a grid on the left pane similar to outlook. on the right pane I have pushpins showing where the vehicle had been in the  specified date range. I need to display the infobox contents based on the pushpin which is hovered. It works fine for a while after making some selections all of a sudden the infobox is not visible. I have put a breakpoint and checked the visible property of the infobox. It is true. but the infobox is still not visible. After some more random trials it becomes visible again. I am sure I have done everything right as per the articles found. Please let me know if I am missing something.

    Regards,

    Murthy

    Tuesday, March 4, 2014 11:16 AM
  • In your code sample you are adding and removing the infobox from the map constantly. Instead create one infobox and just change the visibility. In your code it's possible that if too many events happen at once the infobox will be removed from the map before it is made visible.

    http://rbrundritt.wordpress.com

    Tuesday, March 4, 2014 11:49 AM
  • Hi Ricky

    Thanks for your prompt response. I initially initialized the infobox only once but in that case the infobox is somehow always pointing to the first pushpin only. The title and description seem to be changing but the infobox position is not changing.

    Regards,

    Murthy.

    Tuesday, March 4, 2014 12:40 PM