APIs
Log In
APIs

YoumapsAPI.getMapdataFilters

YoumapsAPI.getMapdataFilters(mapdataId:Integer)

Gets a map containing the lists of all spatial & attribute filters that have been created for a given mapdata.

📘

Prerequisite

You must have loaded all filters through the YoumapsAPI.initMapboardSpatialFilters & YoumapsAPI.initMapboardAttributeFilters methods to use this method.

function onYoumapsApiLoaded(){
  console.log("YoumapsAPI loaded!");
  youmapsApi.initMapboardSpatialFilters(<MAPBOARD_ID>, function(){
  	youmapsApi.initMapboardAttributeFilters(<MAPBOARD_ID>, function(){
    	youmapsApi.getMapdataFilters();
    });
  }); 
}

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 map of spatial & attribute filters returned through the callback has the following format :

{
  spatialFilters : [
    {
      id : <FILTER_ID>,
      name : "Circle Spatial Filter",
      radius : 67088,
      selectedMapdata : "[<MAPDATA_ID_1>,<MAPDATA_ID_2>]",
      type : "circle",
      vertices : "[{"lat":51.24472459284824,"lng":-2.8487205505371094}]"
    },
    {
      id : <FILTER_ID>,
      name : "Polygon Spatial Filter",
      selectedMapdata : "[<MAPDATA_ID_1>]",
      type : "polygon",
      vertices : "[{"lat":51.83577752045248,"lng":-7.101287841796875}{"lat":52.133488040771475,"lng":10.301055908203125},{"lat":48.28319289548349,"lng":8.850860595703125},{"lat":48.28319289548349,"lng":-6.398162841796875}]"
    }
	],
  attributeFilters : [
    {
      conditions : "[{"attribute":"axa_eq_zon","condition":"equal to","value":"2","operator":""}]",
      id : <FILTER_ID>,
      mapboardId : <MAPBOARD_ID>,
      mapdataId : <MAPDATA_ID>,
      name : "Attribute Filter name"
    },
    {
      conditions : "[{"attribute":"axa_eq_zon","condition":"less than","value":"2","operator":""}]",
      id : <FILTER_ID>,
      mapboardId : <MAPBOARD_ID>,
      mapdataId :<MAPDATA_ID>,
      name : "Attribute Filter name"
    }
  ]
}