Filtering within a Polygon

Filtering within a Polygon

Using the Backend Services RESTful API, you can retrieve all content type items that are geographically located within a polygon formed by three or more Geo Points. Telerik Platform supports searches within both concave and convex polygons.

A polygon is specified as an array of points. The last point in the polygon is implicitly connected to the first.

The next example shows how to filter within a polygon formed by four Geo Points.

//Ajax request using jQuery
var filter = {
    "Location": {
        "$within": {
            "$polygon": [
                { "longitude": 22.317871, "latitude": 41.687709 },
                { "longitude": 24.698749, "latitude": 41.698749 },
                { "longitude": 24.331346, "latitude": 42.707075 },
                { "longitude": 22.305597, "latitude": 42.702282 }
            ]
        }
    }
};

$.ajax({
    url: 'https://api.everlive.com/v1/your-app-id/type-name',
    type: "GET",
    headers: {
        "Authorization" : "Bearer your-access-token-here",
        "X-Everlive-Filter" : JSON.stringify(filter)
    },
    success: function(data){
        alert(JSON.stringify(data));
    },
    error: function(error){
        alert(JSON.stringify(error));
    }
})
Request:
    GET https://api.everlive.com/v1/your-app-id/type-name 
Header:
    Authorization  Bearer your-access-token-here
    X-Everlive-Filter {
        "Location": {
            "$within": {
                "$polygon": [
                    { "longitude": 22.317871, "latitude": 41.687709 },
                    { "longitude": 24.698749, "latitude": 41.698749 },
                    { "longitude": 24.331346, "latitude": 42.707075 },
                    { "longitude": 22.305597, "latitude": 42.702282 }
                ]
            }
        }
    }
Response:
    Status: 200 OK
    Content-Type: application/json
Start a free trial Request a demo
Contact us: +1-888-365-2779
sales@telerik.com
Copyright © 2016-2017, Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.