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
-
$marker_data array
Data of the marker, Available parameters for type marker
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
-
$markers_data array
Data of the markers. Available parameters for type marker.
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
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
-
$args array
The parameters of the marker list. Special parameters for marker list action.
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
-
$args array
The parameters of the search. Special parameters for search action.
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
-
$marker_data array
The Data of the marker to update. Available parameters for type marker.
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
-
$markers_data array
The Data of the markers to update. Available parameters for type marker.
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
-
$layer_data array
Data of the layer. Available parameters for type layer.
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
-
$layers_data array
Data of the layers. Available parameters for type layer.
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
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
-
$args array
The parameters of the layer list. Special parameters for layer list action.
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
-
$args array
The parameters of the search. Special parameters for search action.
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
-
$layer_data array
The Data of the layer to update. Available parameters for type layer.
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
-
$layers_data array
The Data of the layers to update. Available parameters for type layer.
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 |
---|---|---|---|---|
id | required | integer | set automatically when adding a new marker | |
markername | optional | string | NULL | |
geocode | optional | string | NULL | 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) | |
lat | optional | float | default location for new marker (see settings) | gets overwritten if parameter geocode is used! |
lon | optional | float | default location for new marker (see settings) | gets overwritten if parameter geocode is used! |
icon | optional | string (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. |
popuptext | optional | string | NULL | |
zoom | optional | integer | default zoom for new marker (see settings) | |
openpopup | optional | boolean | default value for new markers (see settings) | |
mapwidth | optional | integer | default mapwidth for new markers (see settings) | |
mapwidthunit | optional | string | default value for new markers (see settings) | |
mapheight | optional | integer | default mapheight for new markers (see settings) | |
panel | optional | boolean | default value for new markers (see settings) | |
createdby | optional | string | NULL | |
createdon | optional | date (Y-m-d H:i:s) | NULL | |
updatedby | optional | string | NULL | |
updatedon | optional | date (Y-m-d H:i:s) | date('Y-m-d H:i:s) | |
controlbox | optional | boolean | default value for new markers (see settings) | |
overlays_custom | optional | boolean | default value for new markers (see settings) | |
overlays_custom2 | optional | boolean | default value for new markers (see settings) | |
overlays_custom3 | optional | boolean | default value for new markers (see settings) | |
overlays_custom4 | optional | boolean | default value for new markers (see settings) | |
wms | optional | boolean | default value for new markers (see settings) | |
wms2 | optional | boolean | default value for new markers (see settings) | |
wms3 | optional | boolean | default value for new markers (see settings) | |
wms4 | optional | boolean | default value for new markers (see settings) | |
wms5 | optional | boolean | default value for new markers (see settings) | |
wms6 | optional | boolean | default value for new markers (see settings) | |
wms7 | optional | boolean | default value for new markers (see settings) | |
wms8 | optional | boolean | default value for new markers (see settings) | |
wms9 | optional | boolean | default value for new markers (see settings) | |
wms10 | optional | boolean | default value for new markers (see settings) | |
kml_timestamp | optional | date (Y-m-d H:i:s) | NULL | |
address | optional | string | NULL | gets overwritten if parameter geocode is used! |
gpx_url | optional | string | NULL | since v1.2p |
gpx_panel | optional | boolean | 0 | since v1.2p |
Available parameters for type layer
Parameter | Required? | Datatype | Default value | Notes |
---|---|---|---|---|
id | required | integer | set automatically when adding a new marker | |
geocode | optional | string | NULL | value gets geoencoded via Google Places API and overwrites parameter lat, lon and address |
name | optional | string | NULL | |
basemap | optional | predefined values | default 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 |
layerzoom | optional | integer | default zoom for new layer (see settings) | |
mapwidthunit | optional | string | default value for new layer (see settings) | |
mapwidth | optional | integer | default mapwidth for new layer (see settings) | |
mapheight | optional | integer | default mapheight for new layer (see settings) | |
panel | optional | boolean | default value for new layer (see settings) | |
layerviewlat | optional | float | default lat for new layer (see settings) | gets overwritten if parameter geocode is used! |
layerviewlon | optional | float | default lon for new layer (see settings) | gets overwritten if parameter geocode is used! |
createdby | optional | string | NULL | |
createdon | optional | date (Y-m-d H:i:s) | NULL | |
updatedby | optional | string | NULL | |
updatedon | optional | date (Y-m-d H:i:s) | date('Y-m-d H:i:s) | |
controlbox | optional | boolean | default value for new layer (see settings) | |
overlays_custom | required | boolean | default value for new layer (see settings) | |
overlays_custom2 | required | boolean | default value for new layer (see settings) | |
overlays_custom3 | required | boolean | default value for new layer (see settings) | |
overlays_custom4 | required | boolean | default value for new layer (see settings) | |
wms | required | boolean | default value for new layer (see settings) | |
wms2 | required | boolean | default value for new layer (see settings) | |
wms3 | required | boolean | default value for new layer (see settings) | |
wms4 | required | boolean | default value for new layer (see settings) | |
wms5 | required | boolean | default value for new layer (see settings) | |
wms6 | required | boolean | default value for new layer (see settings) | |
wms7 | required | boolean | default value for new layer (see settings) | |
wms8 | required | boolean | default value for new layer (see settings) | |
wms9 | required | boolean | default value for new layer (see settings) | |
wms10 | required | boolean | default value for new layer (see settings) | |
listmarkers | optional | boolean | default value for new layer (see settings) | option to show list of markers below layer maps |
multi_layer_map | optional | boolean | 0 | |
multi_layer_map_list | optional | string (comma-separated layer-IDs or all) | NULL | e.g. 1,2,3,4 or all |
address | optional | string | NULL | gets overwritten if parameter geocode is used! |
delete_markers | optional | true/false | false | when used on delete action, also assigned markers are deleted |
clustering | optional | boolean | default value for new layer (see settings) | available in pro version only |
gpx_url | optional | string | NULL | since v1.2p |
gpx_panel | optional | boolean | 0 | since v1.2p |
Special parameters for marker list action
Parameter | Required? | Data type | Notes |
---|---|---|---|
orderkey | optional | string | Allowed sort order values: id, createdon, updatedon, kml_timestamp, markername, basemap, lat, lon, createdby, updatedby, address |
orderdir | optional | string | Allowed sort direction values: ASC, DESC |
orderoff | optional | integer | Offset for the marker list |
orderlimit | optional | integer | Limit for the marker list |
Special parameters for layer list action
Parameter | Required? | Data type | Notes |
---|---|---|---|
orderkey | optional | string | Allowed sort order values: id, updatedon, createdon, name, basemap, layerviewlat, layerviewlon, createdby, updatedby, address |
orderdir | optional | string | Allowed sort direction values: ASC, DESC |
orderoff | optional | integer | Offset for the layer list |
orderlimit | optional | integer | Limit for the layer list |
Special parameters for search action
Parameter | Required? | Data type | Notes |
---|---|---|---|
searchkey | required | string | Allowed 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 |
searchvalue | depends | string or integer | generally required but optional when using searchkey createdon, updatedon or boundingbox |
date_from | depends | string (Y-m-d H:i:s) | generally optional but required when using searchkey createdon or updatedon |
date_to | depends | string (Y-m-d H:i:s) | generally optional but required when using searchkey createdon or updatedon |
lat_top_left | depends | floatval(6) | generally optional but required when using searchkey boundingbox |
lon_top_left | depends | floatval(6) | generally optional but required when using searchkey boundingbox |
lat_bottom_right | depends | floatval(6) | generally optional but required when using searchkey boundingbox |
lon_bottom_right | depends | floatval(6) | generally optional but required when using searchkey boundingbox |