locked
Calling PointBasedClustering,js file from custom,js file is causing an issue RRS feed

  • Question

  • I am calling PointBasedClusteringmodule from a function in custom.js file

    GetMap function is called on page load and the code resides in custom.js file.

    function GetMap() {
    
            // Initialize the map
        map = new Microsoft.Maps.Map(document.getElementById("MapHolder"),
                   {
                       credentials: "xxxxxxxxxxxxxxx", zoom: 2,
                       mapTypeId: Microsoft.Maps.MapTypeId.road, showDashboard: true,
                       center: new Microsoft.Maps.Location(41.021429, 21.337973)
                   });
        //Nate: 3/26/15: for clustering pushpins
        Microsoft.Maps.registerModule("PointBasedClusteringModule", "~/PointBasedClustering.js");
    
        Microsoft.Maps.loadModule("PointBasedClusteringModule", { callback: moduleLoaded });
    
        Microsoft.Maps.Pushpin.prototype.title = null;
        Microsoft.Maps.Pushpin.prototype.description = null;
    
        //Getlocations function moved to moduleloaded function
    
    }
    
    

    The PointBasedClustering.js file as follows. The error is coming after the module is loaded at

    Microsoft.Maps.moduleLoaded('PointBasedClusteringModule');

    Unhandled exception at line 447, column 1 in http://localhost:52723/Scripts/PointBasedClustering.js

    0x800a1391 - JavaScript runtime error: 'Microsoft' is undefined

    Any ideas on what is causing this.

    Thanks

    Nate

    Wednesday, April 8, 2015 4:02 AM

Answers

  • Verify that you haven't also added a script reference in your HTML to the module. If you have it's likely that this code is being executed before the Bing Maps control is loaded.

    http://rbrundritt.wordpress.com

    • Proposed as answer by Ricky_Brundritt Wednesday, April 8, 2015 4:30 PM
    • Marked as answer by SPTQs Wednesday, April 8, 2015 5:26 PM
    Wednesday, April 8, 2015 4:30 PM