Attentation: the MMPAPI has been removed with v4.0, replacement: Database API

MMPAPI documentation

back to API overview

MMPAPI functions

  1. Introduction
  2. generated class description
  3. Markers
    1. add_marker
    2. add_markers
    3. count_markers
    4. delete_marker
    5. delete_markers
    6. get_marker
    7. get_markers
    8. list_markers
    9. search_markers
    10. update_marker
    11. update_markers
  4. Layers
    1. add_layer
    2. add_layers
    3. count_layers
    4. delete_layer
    5. delete_layers
    6. get_layer
    7. get_layers
    8. list_layers
    9. search_layers
    10. update_layer
    11. update_layers
  5. Permissions
    1. current_user_can_any
  6. Parameters
    1. Available parameters for type marker
    2. Available parameters for type layer
    3. Special parameters for marker list action
    4. Special parameters for layer list action
    5. Special parameters for search action


Introduction

The Maps Marker Pro API Functions provides developers with a future-proof way to access some of the common core functionalities in Maps Marker Pro.

The API Functions are automatically included when Maps Marker Pro loads and they will be available by the time add-ons are loaded. The API class is called MMPAPI and it can be found in /leaflet-maps-marker-pro/inc/class-mmpapi.php.


Generated class description

The automatically generated class description can be found at https://www.mapsmarker.com/wp-content/uploads/mmpapi/class/


Markers

add_marker

Adds a new marker using the given Marker object. Warning, little checking is done to make sure it's a valid Marker object.

public static function add_marker( $marker_data ) {}

Parameters

Returns

Usage Example


$marker_data = array(
	'markername' => 'Headquarter',
	'geocode' => 'Main Street 1 Washington',
);
$marker_id = MMPAPI::add_marker( $marker_data );
back to top


add_markers

Add markers based on given data objects.

public static function add_markers( $markers_data ) {}

Parameters

Returns

  • $markers mixed

    An array of Markers IDs or WP_Error object.

Usage Example


$markers_data = array(
	array(
		'markername' => 'Headquarter',
		'geocode' => 'Main Street 1 Washington',
	),
	array(
		'markername' => 'Headquarter',
		'geocode' => 'Main Street 1 Washington',
	));
$markers = MMPAPI::add_markers( $markers_data );
back to top


count_markers

Returns the number of markers available.

public static function count_markers( ) {}

Returns

  • $markers_count int

    The markers count

Usage Example

$result = MMPAPI::count_markers( );
back to top


delete_marker

Deletes the marker with the given Marker ID.

public static function delete_marker( $marker_id ) {}

Parameters

  • $marker_id integer

    The ID of the Marker to be deleted.

Returns

Usage Example

$result = MMPAPI::delete_marker( $marker_id );
back to top


delete_markers

Deletes the markers for a given Markers IDs

public static function delete_markers( $marker_ids ) {}

Parameters

  • $marker_ids array

    The IDs of the Markers.

Returns

  • $result mixed

    True if the markers deleted successfully, WP_Error object if not.

Usage Example


$marker_ids = array(6,7,8);
$result = MMPAPI::delete_markers( $marker_ids );
back to top


get_marker

Returns the marker object for a given Marker ID.

public static function get_marker( $marker_id ) {}

Parameters

  • $marker_id integer

    The ID of the Marker.

Returns

  • $result mixed

    The marker object or False.

Usage Example

$result = MMPAPI::get_marker( 5 );
back to top


get_markers

Returns the marker objects for given Marker IDs.

public static function get_markers( $marker_ids ) {}

Parameters

  • $marker_ids array

    The IDs of the Markers.

Returns

  • $result mixed

    The marker objects or False.

Usage Example

$result = MMPAPI::get_markers( array( 1, 5, 10 ) );
back to top


list_markers

Returns all marker objects.

public static function list_markers( $args = NULL ){}

Parameters

Returns

  • $result mixed

    The marker objects or False.

Usage Example


$args['orderkey'] = 'markername';
$args['orderdir'] = 'ASC';
$result = MMPAPI::list_markers( $args );
back to top


search_markers

Search markers object for a given arguments.

public static function search_markers( $args ) {}

Parameters

Returns

  • $result mixed

    The marker objects that match the parameters or False.

Usage Example


$args['searchkey'] = 'layer';
$args['searchvalue'] = 7;
$result = MMPAPI::search_markers( $args );
back to top


update_marker

Updates a marker based on given data object

public static function update_marker( $marker_data ) {}

Parameters

Returns

  • $result boolean

    True if the marker has been updated, false otherwise.

Usage Example


$marker_data = array(
					 'id' => 2,
					 'popuptext' => 'new popuptext' 
					 );

$result = MMPAPI::update_marker( $marker_data );
back to top


update_markers

Update markers based on given data object

public static function update_markers( $markers_data ) {}

Parameters

Returns

  • $result mixed

    Array of IDs of updated markers or an error object.

Usage Example


$markers_data = array(
					array(
					 	'id' => 2,
					 	'popuptext' => 'new popuptext for marker#2' 
					 ),
					 array(
					 	'id' => 3,
					 	'popuptext' => 'new popuptext for marker#3' 
					 )
				);

$result = MMPAPI::update_markers( $markers_data );
back to top


Layers

add_layer

Adds a new layer using the given Layer object. Warning, little checking is done to make sure it's a valid Layer object.

public static function add_layer( $layer_data ) {}

Parameters

Returns

Usage Example


$layer_data = array(
	'name' => 'Headquarter',
	'geocode' => 'Main Street 1 Washington',
);
$layer_id = MMPAPI::add_layer( $layer_data );
back to top


add_layers

Add layers based on given data objects.

public static function add_layers( $layers_data ) {}

Parameters

Returns

  • $layers mixed

    An array of Layers IDs or WP_Error object.

Usage Example


$layers_data = array(
	array(
		'name' => 'Headquarter',
		'geocode' => 'Main Street 1 Washington',
	),
	array(
		'name' => 'Headquarter 2',
		'geocode' => 'Main Street 2 Washington',
	));
$layers = MMPAPI::add_layers( $layers_data );
back to top


count_layers

Returns the number of layers available.

public static function count_layers( ) {}

Returns

  • $layers_count int

    The layers count

Usage Example

$result = MMPAPI::count_layers( );
back to top


delete_layer

Deletes the layer with the given Layer ID.

public static function delete_layer( $layer_id, $delete_markers = false ) {}

Parameters

  • $layer_id integer

    The ID of the Layer to be deleted.

  • $delete_markers boolean

    A boolean parameter, if it has set to TRUE, the method will delete all the markers associated with the layer. Default value is FALSE.

Returns

Usage Example

$result = MMPAPI::delete_layer( $layer_id );
back to top


delete_layers

Deletes the layers for a given Layers IDs

public static function delete_layers( $layers_ids, $delete_markers = false ) {}

Parameters

  • $layers_ids array

    The IDs of the Layers.

  • $delete_markers boolean

    A boolean parameter, if it has set to TRUE, the method will delete all the markers associated with the layers. Default value is FALSE.

Returns

  • $result mixed

    True if the layers deleted successfully, WP_Error object if not.

Usage Example


$layers_ids = array(6,7,8);
$result = MMPAPI::delete_layers( $layers_ids );
back to top


get_layer

Returns the layer object for a given Layer ID.

public static function get_layer( $layer_id ) {}

Parameters

  • $layer_id integer

    The ID of the Layer.

Returns

  • $result mixed

    The layer object or False.

Usage Example

$result = MMPAPI::get_layer( 5 );
back to top


get_layers

Returns the layer objects for given Layer IDs.

public static function get_layers( $layer_ids ) {}

Parameters

  • $layer_ids array

    The IDs of the Layers.

Returns

  • $result mixed

    The layer objects or False.

Usage Example

$result = MMPAPI::get_layers( array( 1, 5, 10 ) );
back to top


list_layers

Returns all layer objects.

public static function list_layers( $args = NULL ) {}

Parameters

Returns

  • $result mixed

    The layer objects or False.

Usage Example


$args['orderkey'] = 'name';
$args['orderdir'] = 'ASC';
$result = MMPAPI::list_layers( $args );
back to top


search_layers

Search layers object for a given arguments.

public static function search_layers( $args ) {}

Parameters

Returns

  • $result mixed

    The layers objects that match the parameters or False.

Usage Example


$args['searchkey'] = 'name';
$args['searchvalue'] = 'Washington';
$result = MMPAPI::search_layers( $args );
back to top


update_layer

Updates a layer based on given data object

public static function update_layer( $layer_data ) {}

Parameters

Returns

  • $result boolean

    True if the layer has been updated, false otherwise.

Usage Example


$layer_data = array(
					 'id' => 2,
					 'popuptext' => 'new popuptext' 
					 );

$result = MMPAPI::update_layer( $layer_data );
back to top


update_layers

Update layers based on given data object

public static function update_layers( $layers_data ) {}

Parameters

Returns

  • $result mixed

    Array of IDs of updated layers or an error object.

Usage Example


// Update layers with IDs 2,3 hide list of markers below map 
$layers_data = array(
					array(
					 	'id' => 2,
					 	'listmarkers' => 0
					 ),
					 array(
					 	'id' => 3,
					 	'listmarkers' => 0
					 )
				);

$result = MMPAPI::update_layers( $layers_data );
back to top

Permissions

current_user_can_any

Checks the permissions for the current user. Returns true if the current user has any of the specified capabilities.

IMPORTANT: Call this before calling any of the other API Functions as permission checks are not performed at lower levels.

public static function current_user_can_any( $capabilities ) {}

Parameters

  • $capabilities mixed

    String if you want to check just one capability, or an array of multiple capabilities

Returns

Usage Example


$marker_data = array(
	'markername' => 'Headquarter',
	'geocode' => 'Main Street 1 Washington',
);
if(MMPAPI::current_user_can_any( 'edit_posts' )){
	$marker_id = MMPAPI::add_marker( $marker_data );
}else{
	wp_die('You do not have permessions');
}
back to top


Parameters

Available parameters for type marker

Parameter Required? Datatype Default value Notes
idrequiredintegerset automatically when adding a new marker
markernameoptionalstringNULL
geocodeoptionalstringNULL value gets geoencoded via Google Places API and overwrites parameter lat, lon and address
basemap optional predefined basemap IDs - see notes default basemap for new marker (see settings) osm_mapnik, mapquest_osm, mapquest_aerial, googleLayer_roadmap, googleLayer_satellite, googleLayer_hybrid, googleLayer_terrain, bingaerial, bingaerialwithlabels, bingroad, ogdwien_basemap, ogdwien_satellite, mapbox, mapbox2, mapbox3, custom_basemap, custom_basemap2, custom_basemap3, empty_basemap
layer optional integer default layer for new marker (see settings)
latoptionalfloatdefault location for new marker (see settings) gets overwritten if parameter geocode is used!
lonoptionalfloatdefault location for new marker (see settings) gets overwritten if parameter geocode is used!
iconoptionalstring (e.g. bus.png)NULL if NULL, default icon will be used. Please just use the filename of the icon as stated in the example. All icons available in the icon directory (usually /wp-content/uploads/leaflet-maps-marker-icons if you didnt change it in Settings / map defaults / Default values for marker icons) are available for usage.
popuptextoptionalstringNULL
zoomoptionalintegerdefault zoom for new marker (see settings)
openpopupoptionalbooleandefault value for new markers (see settings)
mapwidthoptionalintegerdefault mapwidth for new markers (see settings)
mapwidthunitoptionalstringdefault value for new markers (see settings)
mapheightoptionalintegerdefault mapheight for new markers (see settings)
paneloptionalbooleandefault value for new markers (see settings)
createdbyoptionalstringNULL
createdonoptionaldate (Y-m-d H:i:s)NULL
updatedbyoptionalstringNULL
updatedonoptionaldate (Y-m-d H:i:s)date('Y-m-d H:i:s)
controlboxoptionalbooleandefault value for new markers (see settings)
overlays_customoptionalbooleandefault value for new markers (see settings)
overlays_custom2optionalbooleandefault value for new markers (see settings)
overlays_custom3optionalbooleandefault value for new markers (see settings)
overlays_custom4optionalbooleandefault value for new markers (see settings)
wmsoptionalbooleandefault value for new markers (see settings)
wms2optionalbooleandefault value for new markers (see settings)
wms3optionalbooleandefault value for new markers (see settings)
wms4optionalbooleandefault value for new markers (see settings)
wms5optionalbooleandefault value for new markers (see settings)
wms6optionalbooleandefault value for new markers (see settings)
wms7optionalbooleandefault value for new markers (see settings)
wms8optionalbooleandefault value for new markers (see settings)
wms9optionalbooleandefault value for new markers (see settings)
wms10optionalbooleandefault value for new markers (see settings)
kml_timestampoptionaldate (Y-m-d H:i:s)NULL
addressoptionalstringNULL gets overwritten if parameter geocode is used!
gpx_urloptionalstringNULL since v1.2p
gpx_paneloptionalboolean0 since v1.2p

back to top


Available parameters for type layer

Parameter Required? Datatype Default value Notes
idrequiredintegerset automatically when adding a new marker
geocodeoptionalstringNULL value gets geoencoded via Google Places API and overwrites parameter lat, lon and address
nameoptionalstringNULL
basemapoptionalpredefined valuesdefault basemap for new layer (see settings) osm_mapnik, mapquest_osm, mapquest_aerial, googleLayer_roadmap, googleLayer_satellite, googleLayer_hybrid, googleLayer_terrain, bingaerial, bingaerialwithlabels, bingroad, ogdwien_basemap, ogdwien_satellite, mapbox, mapbox2, mapbox3, custom_basemap, custom_basemap2, custom_basemap3, empty_basemap
layerzoomoptionalintegerdefault zoom for new layer (see settings)
mapwidthunitoptionalstringdefault value for new layer (see settings)
mapwidthoptionalintegerdefault mapwidth for new layer (see settings)
mapheightoptionalintegerdefault mapheight for new layer (see settings)
paneloptionalbooleandefault value for new layer (see settings)
layerviewlatoptionalfloatdefault lat for new layer (see settings) gets overwritten if parameter geocode is used!
layerviewlonoptionalfloatdefault lon for new layer (see settings) gets overwritten if parameter geocode is used!
createdbyoptionalstringNULL
createdonoptionaldate (Y-m-d H:i:s)NULL
updatedbyoptionalstringNULL
updatedonoptionaldate (Y-m-d H:i:s)date('Y-m-d H:i:s)
controlboxoptionalbooleandefault value for new layer (see settings)
overlays_customrequiredbooleandefault value for new layer (see settings)
overlays_custom2requiredbooleandefault value for new layer (see settings)
overlays_custom3requiredbooleandefault value for new layer (see settings)
overlays_custom4requiredbooleandefault value for new layer (see settings)
wmsrequiredbooleandefault value for new layer (see settings)
wms2requiredbooleandefault value for new layer (see settings)
wms3requiredbooleandefault value for new layer (see settings)
wms4requiredbooleandefault value for new layer (see settings)
wms5requiredbooleandefault value for new layer (see settings)
wms6requiredbooleandefault value for new layer (see settings)
wms7requiredbooleandefault value for new layer (see settings)
wms8requiredbooleandefault value for new layer (see settings)
wms9requiredbooleandefault value for new layer (see settings)
wms10requiredbooleandefault value for new layer (see settings)
listmarkersoptionalbooleandefault value for new layer (see settings) option to show list of markers below layer maps
multi_layer_mapoptionalboolean0
multi_layer_map_listoptionalstring (comma-separated layer-IDs or all)NULL e.g. 1,2,3,4 or all
addressoptionalstringNULL gets overwritten if parameter geocode is used!
delete_markersoptionaltrue/falsefalse when used on delete action, also assigned markers are deleted
clusteringoptionalbooleandefault value for new layer (see settings) available in pro version only
gpx_urloptionalstringNULL since v1.2p
gpx_paneloptionalboolean0 since v1.2p


Special parameters for marker list action

ParameterRequired?Data typeNotes
orderkeyoptionalstringAllowed sort order values: id, createdon, updatedon, kml_timestamp, markername, basemap, lat, lon, createdby, updatedby, address
orderdiroptionalstringAllowed sort direction values: ASC, DESC
orderoffoptionalintegerOffset for the marker list
orderlimitoptionalintegerLimit for the marker list
back to top


Special parameters for layer list action

ParameterRequired?Data typeNotes
orderkeyoptionalstringAllowed sort order values: id, updatedon, createdon, name, basemap, layerviewlat, layerviewlon, createdby, updatedby, address
orderdiroptionalstringAllowed sort direction values: ASC, DESC
orderoffoptionalintegerOffset for the layer list
orderlimitoptionalintegerLimit for the layer list
back to top


Special parameters for search action

ParameterRequired?Data typeNotes
searchkeyrequiredstringAllowed searchkeys: id, markername, basemap, layer, lat, lon, icon, popuptext, zoom, openpopup, mapwidth, mapwidthunit, mapheight, panel, createdby, createdon, updatedby, updatedon, controlbox, overlays_custom, overlays_custom2, overlays_custom3, overlays_custom4, wms, wms2, wms3, wms4, wms5, wms6, wms7, wms8, wms9, wms10, kml_timestamp, address, gpx_url, gpx_panel, name, layerzoom, layerviewlat, layerviewlon, listmarkers, multi_layer_map, multi_layer_map_list, clustering, boundingbox
searchvaluedependsstring or integergenerally required but optional when using searchkey createdon, updatedon or boundingbox
date_fromdependsstring (Y-m-d H:i:s)generally optional but required when using searchkey createdon or updatedon
date_todependsstring (Y-m-d H:i:s)generally optional but required when using searchkey createdon or updatedon
lat_top_leftdependsfloatval(6)generally optional but required when using searchkey boundingbox
lon_top_leftdependsfloatval(6)generally optional but required when using searchkey boundingbox
lat_bottom_rightdependsfloatval(6)generally optional but required when using searchkey boundingbox
lon_bottom_rightdependsfloatval(6)generally optional but required when using searchkey boundingbox
back to top