none
Error in IE rendering the MapControl RRS feed

  • Question

  • I am developing a mapping application using the AJAX v7 control. In development the app runs fine. I deployed it to test an I keep getting this error:

    Error: 'Microsoft' is undefined

    The error is on this piece of code:

     mapTypeId: Microsoft.Maps.MapTypeId.road,

    Which is in my GetMap function

    function GetMap() {
        mapOtions = {
            credentials: credentials,
            mapTypeId: Microsoft.Maps.MapTypeId.road,
            animate: false
    
        };
    
    I tried adding the new keyword before Microsoft.Maps.MapTypeId, and it made it worse. Any suggestions would be helpful. Thanks.


    mark a fisher

    Wednesday, June 5, 2013 4:35 PM

Answers

  • Is the Bing Maps control loaded before you call the GetMap function? If not then that's why this is occurring.

    http://rbrundritt.wordpress.com

    Wednesday, June 5, 2013 7:12 PM

All replies

  • Is the Bing Maps control loaded before you call the GetMap function? If not then that's why this is occurring.

    http://rbrundritt.wordpress.com

    Wednesday, June 5, 2013 7:12 PM
  • Hi Richard,

    Yes, the map is loaded before I call the GetMap() function. I do not have any problems at all in development, or in Firefox. The map doesn't even render in Chrome. Here is how I'm loading the map:

    When the user visits the default page, I am getting their zip code and passing it to the soap services to get their coordinates(latitude, longitude) I just hard coded a zip for example purposes;

    lblCurrentUsersLocation.Text = "19145";
    lblLatlng.Text = GeocodeAddress(lblCurrentUsersLocation.Text);
    LocationResult workcoordinates = new LocationResult();
    workcoordinates.GetCoordinates(lblLatlng.Text);
    hdnLatitude.Value = Convert.ToString(workcoordinates.Latitude);
    hdnLongitude.Value = Convert.ToString(workcoordinates.Longitude);
    Page.ClientScript.RegisterStartupScript(this.GetType(),

    "GetMap","<script language='javascript'> GetMap(); </script>");

    //this loads a default map for each user based on their zip code

    I call the script from my C# code.And then I pass in the hdnLatitude.Value  & hdnLongitude.Value to the GetMap();

    function GetMap() {
        mapOtions = {
            credentials: credentials,
        };
    
        // Initialize the map
        map = new Microsoft.Maps.Map(document.getElementById("myMap"), mapOtions);
    
        //Set the default page map and view settings
        var lat = document.getElementById("hdnLatitude").value;
        var lng = document.getElementById("hdnLongitude").value;
    
        //set the maps view with the users location
        map.setView({ credentials: credentials, zoom: 12, center: new Microsoft.Maps.Location(lat, lng) });
        map.entities.clear();
        var pushpin = new Microsoft.Maps.Pushpin(map.getCenter(lat, lng), { text: '1' });
        map.entities.push(pushpin);
        pushpin.setLocation(new Microsoft.Maps.Location(lat, lng));
    
    }

    I then load a different map on the same page after a postback depending on some user selections. This map2 has pushpins and infoboxes. I followed the instructions on one of your blogs. This is working fine, the only quirk is that the map displays a "world view" when it loads with the pins and the user has to zoom in to see the pins/infoboxes.

    //displays the results of a search on the default page, with push pins and infoboxes
    function GetResultsMap() {
        var map = null;
    
    
        // Initialize the map
        map = new Microsoft.Maps.Map(document.getElementById("myMap"),
                             {
                                 credentials: credentials,
                                 mapTypeId: Microsoft.Maps.MapTypeId.road
                             });
        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);
    
        AddData();
        map.setView({ bounds: viewBoundaries });
    
    
    }
    function AddData() {
    
        var mi = "miles";
        var locationAry = [];
        //Use the jQuery .each() function to get each item
        $("td.locationDetails").each(function (i, elem) {
            var liListContent = {};
            liListContent.centerName = $(this).find(".hcName").html();
            liListContent.centeraddress = $(this).find(".address").html();
            liListContent.centerCity = $(this).find(".city").html();
            liListContent.centerState = $(this).find(".state").html();
            liListContent.centerZip = $(this).find(".zip").html();
            liListContent.centerPhone = $(this).find(".phone").html();
            liListContent.centerDistance = $(this).find(".distance").html();
            liListContent.centerId = $(this).find(".locationId").html();
            liListContent.centerLatitude = $(this).find(".lat").html();
            liListContent.centerLongitude = $(this).find(".lng").html();
            locationAry[i] = liListContent;
        });
        for (var i = 0; i < locationAry.length; i++) {
    
            var title = locationAry[i].centerName;
            var address = locationAry[i].centeraddress;
            var city = locationAry[i].centerCity;
            var state = locationAry[i].centerState;
            var zip = locationAry[i].centerZip;
            var phone = locationAry[i].centerPhone;
            var distance = locationAry[i].centerDistance;
            var latitude = parseFloat(locationAry[i].centerLatitude);
            var longitude = parseFloat(locationAry[i].centerLongitude);
            var pinLocations = new Microsoft.Maps.Location(parseFloat(locationAry[i].centerLatitude), parseFloat(locationAry[i].centerLongitude));
            var description = locationAry[i].centerName + '<br/>' + locationAry[i].centeraddress + '<br/>' + locationAry[i].centerCity + ' , ' +
                 locationAry[i].centerState + '<br/>' + locationAry[i].centerPhone;
    
            for (p = 1; p < locationAry.length; p++) {
                p = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(parseFloat(locationAry[i].centerLatitude), parseFloat(locationAry[i].centerLongitude)));
                p.Title = distance;
                p.Description = description;
                Microsoft.Maps.Events.addHandler(p, 'click', displayInfobox);
                dataLayer.push(p);
                viewBoundaries = Microsoft.Maps.LocationRect.fromLocations(pinLocations);
    
            }
    
        }
    
        function displayInfobox(e) {
            if (e.targetType == 'pushpin') {
                infobox.setLocation(e.target.getLocation());
                infobox.setOptions({ visible: true, showPointer: true, title: e.target.Title, description: e.target.Description });
            }
        }
    }
    I am not getting any errors in the browsers in dev. But I am getting the errors I mentioned earlier.

    mark a fisher

    Wednesday, June 5, 2013 11:37 PM