0
votes

I am using Ajax to call the C# from Javascript and load the data from database.

I have used following article to show the pushpins and there infoboxes.

http://blogs.msdn.com/b/rbrundritt/archive/2013/11/08/multiple-pushpins-and-infoboxes-in-bing-maps-v7.aspx?CommentPosted=true#commentmessage

My code works great on IE 11 , when I have compatibility mode on,

but when compatibility mode is off, the mouse click event is not being received by the Javascript function.

I tried using Chrome and I had the same issue.

<%@ Page Title="" Language="C#" MasterPageFile="~/Maps.Master" AutoEventWireup="true" CodeBehind="BingMaps.aspx.cs" Inherits="MyMaps.secure.BingMaps" %>

....

<asp:ScriptManager ID="ScriptManager" runat="server"
   EnablePageMethods="true" />

<asp:Literal ID="Literal1" runat="server">
      </asp:Literal>

var map = null, infobox, dataLayer; $(document).ready(function () { GetMap();

    });
    function GetMap() {
        // Initialize the map
        map = new Microsoft.Maps.Map(document.getElementById("MapHolder"),
                   { credentials: "lincensekey", zoom: 2 });

        dataLayer = new Microsoft.Maps.EntityCollection();
        map.entities.push(dataLayer);

        var infoboxLayer = new Microsoft.Maps.EntityCollection();
        map.entities.push(infoboxLayer);

        infobox = new Microsoft.Maps.Infobox(new Microsoft.Maps.Location(0, 0), { visible: false, offset: new Microsoft.Maps.Point(0, 20) });
        infoboxLayer.push(infobox);
        PageMethods.GetLocations(RequestCompletedCallback, RequestFailedCallback);

    }

    function AddData(MapPoints) {


        for (var i = 0, len = MapPoints.length; i < len; ++i)
        {
            var pushpin = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(parseFloat(MapPoints[i].lat),parseFloat(MapPoints[i].lon))
                , {
                        icon: MapPoints[i].group,
                        height: 50, width: 60, text: MapPoints[i].city
                    });
            pushpin.Title = MapPoints[i].name;
            pushpin.description = MapPoints[i].desc;
            Microsoft.Maps.Events.addHandler(pushpin, 'click', displayInfobox);
            dataLayer.push(pushpin);
        }
    }

    function displayInfobox(e) {
        if (e.targetType == 'pushpin') {
            infobox.setLocation(e.target.getLocation());
            infobox.setOptions({ visible: true, title: e.target.Title, description: e.target.description });
        }
    }

    function RequestCompletedCallback(result) {
        result = eval(result);
        AddData(result);
    }

    function RequestFailedCallback(error) {
        var stackTrace = error.get_stackTrace();
        var message = error.get_message();
        var statusCode = error.get_statusCode();
        var exceptionType = error.get_exceptionType();
        var timedout = error.get_timedOut();

        alert("Stack Trace: " + stackTrace + "<br/>" +
            "Service Error: " + message + "<br/>" +
            "Status Code: " + statusCode + "<br/>" +
            "Exception Type: " + exceptionType + "<br/>" +
            "Timedout: " + timedout);
    }
1

1 Answers

0
votes

The pointer events in the SVG standard are implemented slightly differently in IE 11, chrome and firefox with respect to previous versions.

I had to set the container div with pointer-events:none, to receive the mouse events.

<div class="divRow" style="pointer-events: none;">
                <div id="MapHolder" style="width:900px; height:540px;display:block; margin-left:5px;top:2px; ">
                </div>
            </div>