Given a postcode and a maximum search distance, enter the surrounding zip codes. The output is sorted from near to far.
Use one of the two mandatory parameters:
undefined/v1/range?auth_key=YOUR_AUTH_KEY&nl_fourpp=5408
This request gives the following result:
{
"status": "ok",
"results": [
{
"nl_fourpp": "5408",
"distance": 0,
"lng": 5.6584,
"lat": 51.6434
},
{
"nl_fourpp": "5405",
"distance": 1486,
"lng": 5.6475,
"lat": 51.655
},
{
"nl_fourpp": "5404",
"distance": 2966,
"lng": 5.6175,
"lat": 51.6516
},
...
]
}
Please note: the validity of city_key is limited. In practice, the key will be valid for at least 24 hours.
The range method is demonstrated in these ready-to-use examples:
We encourage you to request example code in the language you prefer. In the meantime, you might want to look at the autocomplete method, which is already demonstrated in many languages.
We start by creating an empty HTML page, containing a minimal web page structure.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Range tutorial</title>
</head>
<body></body>
</html>
Download our JavaScript library range.js that allows us to integrate the Pro6PP webservice into this web page. Copy it in the same directory as you saved the above web page.
Add the following code between the <body> and </body> tags.
It adds the input fields for entering the postcode.
<form action="#" class="pro6pp_range">
Postcode: <input class="postcode" maxlength="4" /><br />
Range:
<select class="range">
<option value="5" selected="selected">5 km</option>
<option value="15">15 km</option>
<option value="50">50 km</option>
</select>
<span class="message"></span><br />
<div class="output"></div>
</form>
Add the following code between the <head> and </head> tags.
<script src="https://code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="range.js"></script>
<script>
var pro6pp_auth_key = 'YOUR AUTH_KEY';
$(document).ready(function() {
$('.pro6pp_range').applyRange();
});
</script>
To access the Pro6PP webservice, you need to request your personal authorization key. This key is emailed to you right after signing up.
Replace the above placeholder YOUR AUTH_KEY with your personal authorization key.
Open range.html in your browser. It‘s ready to use!
It doesn‘t work? Try downloading the ready-to-use example code at the example code page.
Show the found results in a different way. Replace this JavaScript line...
$(".pro6pp_range").applyRange();
...with the following code:
$(".pro6pp_range").applyRange({ 'assemble_func': assemble_one });
// This function is called for each postcode found.
function assemble_one(result) {
return "Distance to " + result.nl_fourpp + " is " +
result.distance + " meters from your location.<br />";
}
You can see the pattern here. Instead of nl_fourpp and distance you may use any of these fields to construct your output: lat, lng.
Instead of adding classes to your form, you can instruct applyRange() to use custom field identifiers. jQuery selector syntax is accepted.
This example overrides the default identifier of the fields by using their name or id attributes.
... Postcode: <input name="zipcode" />
<span id="range-errors"></span>
... ... $(document).ready(function() { $(this).applyRange({ postcode: 'input[name="zipcode"]',
message: '#range-errors', }); });
You can see the pattern here. Instead of the postcode and message parameters, you may use any of these:
Parameter range assigns the input or select element containing search ranges to choose from.
Parameter message assigns the container element in which to display error messages.
Parameter spinner assigns an (image) element to hide/show during API communication. Parameter output assigns the container element in which to display results.