davestacey
2/17/2015 - 8:27 PM

Utility functions to get the US and Canada json feature shapes

Utility functions to get the US and Canada json feature shapes

      // Get the us-state features array
      function getUSfCollection(featureFilePath, callback){
        var stateFile = featureFilePath;
        // state file is .js so...
        $.getScript( stateFile )
          .done(function( script, textStatus ) {
            callback(null, statesData);
          })
          .fail(function( jqxhr, settings, exception ) {
            console.error(" Error getting stateFile.", exception)
            callback("Cannot reach stateFile " + exception);
            return false;
        });
      } //getUSfCollection

      // Get the us-state features array
      function getCanadafCollection(provinceFilePath, callback){
        var provinceFile = provinceFilePath;
        // state file is json so...
        $.getJSON(provinceFile, function(data) {
          callback(data);
        })//function(data) 
        .fail(function() {
          console.error( "getCanadafCollection getJSON error!" );
        });
      } //getUSfCollection