none
Issue with Location in BingMaps, show a satellite image of a location RRS feed

  • Question

  • I am calling following javascript function and passing lat ,lon as strings from .Net

    I am getting following error, 

    Unhandled exception at line 214, column 13 in http://.../SamplePage.aspx
    0x800a138f - JavaScript runtime error: Unable to get property 'Location' of undefined or null reference

            function satMap(lat,lon) {
                // Initialize the satmap
                //loc = new Microsoft.Map.Location(parsefloat(lat),parsefloat(lon));
                map1 = new Microsoft.Maps.Map(document.getElementById("satellitemap"),
                           { credentials: "map key", zoom: 7, mapTypeId: Microsoft.Maps.MapTypeId.satMap, 
                           showDashboard: false
                           });
                var latVal = parseInt(lat);
                var longVal = Microsoft.Maps.Location.normalizeLongitude(parseInt(lon));
                map1.setView({ center: new Microsoft.Map.Location(latVal,longVal) });
                
    
            }
    

    any ideas on what could be wrong?

    Thank you

    Nate

    Thursday, January 29, 2015 7:38 AM

Answers

  • The issue is that you are setting the mapTypeId of the map to an invalid value (satMap). This results in the map type being undefined and breaks all the calculations used to position a location on the map. Try setting this value to Microsoft.Maps.MapTypeId.aerial

    All valid options are documented here: https://msdn.microsoft.com/en-us/library/gg427625.aspx


    http://rbrundritt.wordpress.com

    • Proposed as answer by Ricky_Brundritt Thursday, January 29, 2015 4:39 PM
    • Marked as answer by SPTQs Thursday, January 29, 2015 4:57 PM
    Thursday, January 29, 2015 4:39 PM

All replies