CM Map Locations (CMML) - External API - Adding Locations Based on Current Location (REST API)
Adding Locations From External Services (REST API)
You can build an app with these buttons: "Create Location" and "Track Location".
- Generate Location - When accessed, creates a location entry in the plugin. Read more below
- Track Location - When accessed, starts tracking the user location in real time (Read the separate guide)
What is This Feature
It's possible to track the user location and send that information to the plugin.
How To Add Location Entry Based on GPS Location
Using the feature is simple:
- Adjust the settings (read more below)
- Create or generate a key
- Customize the URL, including the key
- Add the URL to your app
Generate Location URL - How to Use
The URL you will add in your is structured like this:
http://your-site.com/wp-json/cmloc/v1/add_location?description=yourdescription&name=your location name&LocCAT=category&LocLAT=50.401699&LocLONG=30.252512&key=abc123
The underlined green elements above can be customized.
- images (encode the images URL with base64. Example online tool)
- key - has to match the key set in the plugin's settings:
Example with all attributes
b250ZW50L3RoZW1lcy9EaXZpL2hvbWVwYWdlNC9pbWFnZXMvQi93b3JkcHJlc3Mtc3EucG5n &loc-address= 5th Street 29A&loc-postal-code= 012345&loc-phone-number= 11222333&loc-email= email@example.com&loc-website= example.com/&key= 6240e806-3001-4164-81
Navigate to the Admin Dashboard → CM Maps Route Manager → Settings. Click on the Setup tab.
All settings are located under the Location REST API section.
- Enable REST API - Enable this feature
- API key for adding location via REST API - Create your own key or click the button to generate a random one. This field is obligatory.
- Enter the IP from which you can connect - Leaving it empty allows connections from any IP - this might not be secure!
To add multiple IPs, separate them with commas. For example: 220.127.116.11, 18.104.22.168, 22.214.171.124 etc.
- Create category if it doesn't exist - Enabled to let the plugin create the category if it doesn't exist
- Don't add locations with the same name - Enable to prevent the plugin from creating locations with repeated names