APIs
Log In
APIs

YoumapsAPI class

YoumapsAPI({techID:Integer, mapDivId:String, mapOptions?:google.maps.MapOptions, initMapboards?:Boolean}, callback?:Function)

YoumapsAPI is a JavaScript class available in the JavaScript library.
It is the entry point to the JavaScript library, allowing you to load a Google Map as well as mapboards and mapdata.

This class can be instantiated as follows :

function onYoumapsApiLoaded(){
  console.log("YoumapsAPI loaded!");
}
                            
var mapOptions = {  
  center : new google.maps.LatLng(48.858386, 2.343435), // Paris,
  zoom : 11,
  minZoom : 6,
  maxZoom : 17
};

var youmapsApi = new YoumapsAPI(
  {
    techID : <YOUR_TECH_ID>, 
    initMapboards : true,
    mapDivId : "map",
    mapOptions : mapOptions
  },
  onYoumapsApiLoaded
);

The YoumapsAPI constructor allows you to specify 2 parameters.

The first one, in JSON format, contains the following fields :

  • techID : your technical account ID. Click here to learn how to retrieve it.
  • initMapboards : true or false. False if you do not want to load all mapboards shared with the technical account at initialization time. Keep in mind though that you will have to load them manually later on if you intend to access their data. If set to true, all mapboards that have been shared with the technical account are loaded and added to YoumapsAPI.mapboardArray and YoumapsAPI.mapboardHash.
  • mapDivId : the id of the HTML division where you want the Google map to be loaded.
  • mapOptions (optional) : the options you wish to apply to your Google map. Take a look to Google's online documentation to get to know these options.

The second parameter (optional) allows you to specify a method that will be called (callback) once the library has been fully initialized.

The YoumapsAPI object allows you to easily retrieve the initialized mapboards as follows:

  • Use YoumapsAPI.mapboardArray to get an array containing the initialized Mapboard instances.
  • Use YoumapsAPI.mapboardHash to get a hash containing the same mapboards with their IDs as hash keys.