CM Map Locations (CMML) - How To - Add Locations From External Services (REST API)
Adding Locations From External Services (REST API)
What is This Feature
It's possible to add locations to your website from external services.
You can build an app with the button "Create Location". When clicked, it generates a location based on the user's GPS information.
This feature was introduced in version 2.4.0.
How To Use This Feature
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
The URL you will add 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: 126.96.36.199, 188.8.131.52, 184.108.40.206 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