Add Multimedia Content to a Route Destination

See files for this Use Case on GitHub here

You can add a file with multimedia content as a note to any route destination. For more detailed instructions, go to the support portal in Route4Me's official web application (see link )

Description

It's useful to have the ability to attach a file with multimedia content to a route destination. A picture of a particular building or entrance may help users find their destinations faster.

You can only use files with the following extensions: CSV, XLS, PDF, JPG, JPEG, GIF, PNG, DOC, DOCX. For other file types, you should be able to insert it into a Word file and use that.

Solution

Optimization Parameters and addresses

Let's choose a Single Driver Round Trip option for this Use Case. Here are the parameters for this optimization:

ParameterTypeDescriptionHTTP method
api_keystringAPI KEY of the userGET
redirectintegerIf equal to 1, will be redirected, if 0 - notGET
addressesarrayValid JSON array of Address objects. Click here to see the JSON SchemaPOST
parametersRoute ParametersValid JSON string of RouteParameters object. Click here to see the JSON SchemaPOST

You can see the addresses on the map as:

Create an Optimization

The cURL example below shows you how to create new optimized routes for this Use Case:

ParameterTypeDescription
api_keystringAPI KEY of the user
input dataPOST dataValid JSON object string. Click here to see the JSON Schema
1 @ECHO OFF
2 
3 :: Single Driver Round Trip
4 ::See video tutorial here: http://support.route4me.com/route-planning-help.php?id=manual0:tutorial2:chapter1:subchapter1
5 
6 SET URL=https://www.route4me.com/api.v4/optimization_problem.php
7 SET apikey=11111111111111111111111111111111
8 
9 ECHO ON
10 
11 curl -o file1.txt -g -X POST -k -d "@single_driver_round_trip_data.json" "%url%?api_key=%apikey%"
12 
13 timeout /t 30

You can expect an Optimization Problem (see link), which has generated a route already.

View the Optimization details

You can get more details from the newly created Optimization Problem.

The endpoint: https://www.route4me.com/api.v4/optimization_problem.php

HTTP Parameters

AttributeTypeDescriptionHTTP
method
api_keystringAPI KEY of the userGET
optimization_problem_idstringOptimization problem IDGET


1 @ECHO OFF
2 
3 SET url=https://www.route4me.com/api.v4/optimization_problem.php
4 SET apikey=11111111111111111111111111111111
5 SET optprobid=69E1F364F7D2B78FBE9FFB37A0755CEB
6 
7 ECHO ON
8 curl -o file1.txt -g -X GET -k "%URL%?api_key=%apikey%&optimization_problem_id=%optprobid%"
9 
10 timeout /t 30

See sample RESPONSE JSON data here

In the RESPONSE you can see an array of the addresses, which belong to one round trip route.

Details of the Optimized Route

You can get more details of this route.

The endpoint: https://www.route4me.com/api.v4/route.php

HTTP Parameters

AttributeTypeDescriptionHTTP
method
api_keystringAPI KEY of the userGET
route_idstringRoute IDGET
route_path_outputstringIf equal to 'Poitns', you'll get an array of the path points to next addressGET


1 @ECHO OFF
2 
3 SET url=https://www.route4me.com/api.v4/route.php
4 SET apikey=11111111111111111111111111111111
5 SET routeid=EDE99139F62A036E9651D4A2AD168E81
6 SET rpo=Points
7 
8 ECHO ON
9 
10 curl -o file1.txt -g -k -X GET "%url%?route_id=%routeid%&api_key=%apikey%&route_path_output=%rpo%"
11 
12 timeout /t 30

See sample RESPONSE JSON data here

Note
In the RESPONSE you can see the array of the fields path_to_next and use them to draw routes on a map, exactly as they were generated by the Route4Me API.

You can draw the generated round trip route as:

Compare it to the drawing of the official Route4Me website:

Add a note to a destination

You can add a file to any route destination.

The endpoint: https://www.route4me.com/actions/addRouteNotes.php

HTTP Parameters (see JSON schema here)

Attribute Type Description HTTP
method
api_key string API KEY of the user GET
route_id string Route ID GET
address_id intenger Route destination ID GET
dev_lat double The latitude location of where a mobile device was located when it made a request GET
dev_lng double The longitude location of where a mobile device was located when it made a request GET
device_type string The type of the device that is creating this route ENUM("web", "iphone", "ipad", "android_phone", "android_tablet") GET
strUpdateType string The type of the device that is creating this route ENUM("web", "iphone", "ipad", "android_phone", "android_tablet") GET
strFilename string Filename ID POST


Run this batch script with the cURL command:

1 @ECHO OFF
2 
3 :: Add a note to the route:
4 
5 SET url=https://www.route4me.com/actions/addRouteNotes.php
6 SET apikey=11111111111111111111111111111111
7 SET routeid=EDE99139F62A036E9651D4A2AD168E81
8 SET addrid=178141214
9 SET dev_lat=33.132675170898
10 SET dev_lng=-83.244743347168
11 SET dev_type=web
12 SET "filename=single_driver_addresses.jpg"
13 
14 ECHO ON
15 
16 curl -o file1.txt -g -k -X POST -F "strFilename=@%filename%" "%url%?api_key=%apikey%&route_id=%routeid%&address_id=%addrid%&dev_lat=%dev_lat%&dev_lng=%dev_lng%&device_type=%dev_type%&strUpdateType=ANY_FILE"
17 
18 timeout /t 30

You'll get this API response:

{
"status": true,
"note_id": "689835",
"upload_id": "8ae0cc75fccd99b9cf3c28ec539cb5fd",
"note": {
"note_id": 689835,
"route_id": "EDE99139F62A036E9651D4A2AD168E81",
"route_destination_id": 178141214,
"ts_added": 1471422367,
"activity_type": "",
"upload_id": "8ae0cc75fccd99b9cf3c28ec539cb5fd",
"upload_extension": "jpg",
"upload_url": "http:\/\/adb6def9928467589ebb-f540d5a8d53c2e76ad581b6e5c346ad6.r74.cf1.rackcdn.com\/8ae0cc75fccd99b9cf3c28ec539cb5fd.jpg",
"upload_type": "ADDRESS_IMG",
"contents": "",
"lat": 33.132675,
"lng": -83.244743,
"device_type": "web"
}
}

Pay attention to the upload_url parameter. You can enter it in the browser's address bar and see the content of the file directly in your browser (click here)

Also, it's noteworthy that in the strUpdateType parameter we have put the value ANY_FILE, but in response we get ADDRESS_IMG - that's the right value for this particular Use Case example.

Retrieve information about uploaded note file.

As mentioned above, you can see the uploaded file directly in a browser by entering the upload_url parameter value into the browser's address field.

But you can also retrieve information about the uploaded file programmatically.

The endpoint: https://www.route4me.com/api.v4/address.php

HTTP Parameters

Attribute Type Description HTTP
method
api_key string API KEY of the user GET
route_id string Route ID GET
route_destination_id intenger Route destination ID GET
notes integer If equal to 1, response with notes will be returned, if not - without notes. GET


Run this batch script:

1 @ECHO OFF
2 
3 SET url=https://www.route4me.com/api.v4/address.php
4 SET apikey=11111111111111111111111111111111
5 SET routeid=EDE99139F62A036E9651D4A2AD168E81
6 SET routedestinationid=178141214
7 
8 ECHO ON
9 curl -o file1.txt -g -k -X GET "%url%?api_key=%apikey%&route_id=%routeid%&route_destination_id=%routedestinationid%&notes=1"
10 
11 timeout /t 30

See sample RESPONSE JSON data here

Pay attention to the notes parameter.

You can show a note on the map at the destination with:

And by clicking on the marker, you can show the image in the browser. Tip: If you are using GMap.net control, you can save the upload_url value in the tag property and in the OnMarkerClick event handler launch browser with this URL address.