CM Map Locations (CMML) - External API - Tracking User Location in Real Time (REST API)


Tracking User Location in Real Time(REST API)

Back to User Guide

REST API Uses

You can build an app with these buttons: "Create Location" and "Track Location".

  1. Generate Location - When accessed, creates a location entry in the plugin (read the separate guide)
  2. Track Location - When accessed, starts tracking the user location in real time

What is This Feature

It's possible to track the user location and send that information to the plugin.

Example


How To Use Track User Location

Using the feature is simple:

  1. Adjust the settings (read more below)
  2. Create or generate a key
  3. Customize the URL, including the key
  4. Add the URL to your app

Track Location URL - How to Use

The URL you will add in your app is structured like this:

http://your-site.com/wp-json/cmloc/v1/current_location?key=abc123&username=name of user&ip=user IP&coordinates=latitude,longitude&description=yourdescription&type=1

The underlined green elements above can be customized. 

  • username (name of user can be anything and not related to a WP user)
  • ip (IP address)
  • description (any text)
  • type=1 - this parameter is needed to pass current location
  • coordinates (latitude,longitude) - this parameter is needed to pass current location
  • latitude - this parameter is needed to pass temporary location
  • longitude - this parameter is needed to pass temporary location
  • bgcolor - User marker label background color, You can add it with and without "#", e.g. #ff0000, #008000, FFFFFF etc
  • bgcolor_label - User marker label background color text. You can add any text, e.g. Red, Green, Blue etc. And this is used in the filter
  • polygon - the client needs to pass coordinates set in polygon=[polygon]
  • key - has to match the key set in the plugin's settings:

Example with attributes for posting Current Location

https://example-site.com/wp-json/cmloc/v1/current_location?key=xxxx-xxxx&username=admin&ip=128.64.32.137&coordinates=40.758666,-73.976237&description=testlocation&type=1 

Example with attributes for posting Temporary Location

https://example-site.com/wp-json/cmloc/v1/current_location?key=xxxx-xxxx&username= admin&ip=128.64.32.137&latitude=40.758690&longitude=-73.978688&description=testlocation 


Plugin Settings

Navigate to the Admin Dashboard  CM Maps Route Manager  Settings. Click on the User Tracking tab.

User Tracking

  • Enable User Tracking - Turn on feature
  • Track N users - How many devices can connect to the API and. 0 means then no limit, which might be dangerous
  • User position's icon URL - Example:
    https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png
  • Display tooltip on marker - If enabled, a tooltip will show on marker when the user will clicks on it
  • Template for the user track position info window content:
    You can use HTML and the following placeholders: 
    • [identifier]
    • [name] 
    • [description] 
    • [coordinates] 
    • [UTMcoordinates] (note: this placeholder was introduced in version 2.7.5)
    • [updatedate] 
    • [timezone] 
    • [downloadlink]
    • [bgcolor] (note: this placeholder was introduced in version 2.6.6)
    • [bgcolorlabel] (note: this placeholder was introduced in version 2.6.6)
  • User path line type - Choose between
    • No Line (just the points will show on map)
    • Solid Line
    • Dashed Line
  • Line color - Will be applied to the user track if either "Solid" or "Dashed" was selected above
  • Only show last position - If enabled, only shows the user last position. If disabled, shows all
  • Time of last reported tracks - Set time of last X hours:minutes e.g. 01:00 (1 hour), 5:15 (5 hour and 15 minutes), 7:30 (7 hours and 30 minutes), 9 (9 hours) and If set 0 means show always. Note this will work if above setting is disabled.
  • Timezone - Self explanatory
  • Time Format - Choose between 12H and 24H
  • Display user track position on index page map - Shows locations in the map on the index page
  • Display label background color filter on index page - Enable it to allow users to filter user track position by label background color on index page. This option works only if the option Display user track position on index page map is enabled (note: this option was introduced in version 2.6.6)
  • Display time filter on index page - Enable it to allow users to filter user track position by time on index page. This option works only if the option Display user track position on index page map is enabled (note: this option was introduced in version 2.6.7)
  • Display identifier filter on index page - If enabled, the user will be able to filter user track position by identifier on index page on the front-end. Note: this option was introduced in version 2.7.5.
  • Reset user tracking table - Click it to delete all user tracking entries from the table. Note: this option was introduced in version 2.7.2.

Temporary Locations

Note: this section with options was introduced in version 2.7.2.
  • Display temporary locations on index page map - If enabled, then user posted temporary locations will be shown on locations index page map.
  • Location's icon URL - Put here a URL to the location's icon.
  • Display tooltip on marker - If enabled, then a tooltip will be shown on the marker when the user clicks on it.
  • Template for the temporary location info window content - You can use HTML to customize this template. It also supports the following shortcodes: 
    • [name] 
    • [description] 
    • [coordinates] 
    • [updatedate] 
    • [deletelink] (note: will work only for admin privilege user and return output with anchor tag)
  • Location's expire time - Choose location's expire time. You can choose between:
    • 12 hours
    • 24 hours
    • 48 hours
  • Reset temporary location table - Click it to delete all temporary location entries from the table.

Temporary Polygons

Note: this section with options was introduced in version 2.7.3.
  • Display temporary polygons on index page map - If enabled, then user posted temporary polygons will be shown on locations index page map.
  • Display tooltip on polygon - If enabled, then a tooltip will be shown on polygon when user will click on it.
  • Template for the temporary polygon info window content - You can use HTML and the following shortcodes: 
    • [name] 
    • [description] 
    • [coordinates] 
    • [polygoncoordinates] 
    • [updatedate] 
    • [deletelink] (note: will work only for admin privilege user and return output with anchor tag)
  • Polygon's expire time - Choose ploygon's expire time. You can choose between:
    • 12 hours
    • 24 hours
    • 48 hours
  • Reset temporary polygon table - Click it to delete all temporary polygon entries from the table.

More information about the CM Map Routes Manager WordPress Plugin

Other WordPress products can be found at CreativeMinds WordPress Store

Let us know how we can Improve this Product Documentation Page

To open a Support Ticket visit our support center
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us