Skip to content

Search API

POST Polygon Search

This type of search will return results that are within a custom polygon shape. The polygon is defined by a series of points (coordinates) that end with the same point it started with.

Resource URL

https://www.mapquestapi.com/search/v2/polygon

Resource Information

Response FormatsJSON, XML
AuthenticationYes (Requires Key)
Rate LimitedYes

URL Parameters

URL ParameterDescriptionRequired
keyThe API Key, which is needed to make requests to MapQuest services.Yes
inFormatSpecifies the format of the request body. Must be one of the following, if supplied:
  • json
  • xml
Defaults to json if not supplied
No
outFormatSpecifies the format of the response. Must be one of the following, if supplied:
  • json
  • xml
Defaults to json if not supplied
No
ambiguities
String
Use this parameter to set the strategy for resolving ambiguous location names.

If this parameter is set to ignore, the Search Service will simply use the first location found for an address.

If this parameter is not set, or set to a value other than ignore, the Search Service will return a full list of the possible location matches in the collections attribute of the response.
No
callbackA JavaScript function name. The JSON-formatted response will be wrapped in a call to the supplied callback function name to provide JSONP functionality. This functionality might be needed to do cross-site scripting. See the Wikipedia.org entry for JSON for more details.No

Body Parameter

Body ParameterDescriptionRequired
polygon
Polygon
A string of points to make up a polygon. The first and the last point should match to complete the polygonal shape.Yes - This is a required parameter if the locations parameter is not supplied!
locations
Location[]
Using this parameter you can enter addresses to form a polygon shape. Same rule applies as above, the first and last locations must match.Yes - This is a required parameter if the polygon parameter is not supplied!
hostedDataList
List of Hosted Data Objects
HostedData objects will contain data hosted by MapQuest. This includes tables of points of interest from around the world, as well as allowing users to upload data to our servers for it to be stored. This parameter allows you to query these data sets as part of your search request. Refer to the Hosted Data page for more information.No
remoteDataList
List of RemoteData Objects
RemoteData objects contain data provided by the user as part of the request that will be included in the search. Refer to the Remote Data page for more information.No

Body Options Parameters

Body ParametersDescriptionRequired
units
String
Specifies the type of units to use when calculating distance. Search results are then ordered by distance from lowest to highest. Notice there are some additional parameters here than in our other services. Acceptable values are:
  • m - Miles - Sorts the results by straight line distance in miles (straight line distance).
  • k - Kilometers - Sorts the results by straight line distance in kilometers (straight line distance).
  • wmin - Walking Minutes - Sorts the results by shortest walking time (calculated as an actual walking route).
  • dmin - Drive Minutes - Sorts the results by shortest driving time (calculated as an actual driving route).
  • dm - Drive Miles - Sorts the results by shortest driving distance in miles (calculated as an actual driving route).
  • dk - Drive Kilometers - Sorts the results by shortest driving distance in kilometers (calculated as an actual driving route).
Default value is m
No
shapeFormat
String
These shapeFormats are also described in more detail on the Geometry page. Shape format options:
  • raw - shape is represented as float pairs
  • cmp - shape is represented as a compressed path string with 5 digits of precision
  • cmp6 - Same as for cmp, but uses 6 digits of precision.
  • simple - WKT standard for Simple Features.
See the Compressed Lat/Lng description page for more detail, including sample source code and an interactive encoder/decoder.
See the Simple Features Wiki description page for more detail.
No
maxMatches
Integer
This is the number of results returned in the response. While the limit for the maximum number of results returned is 500, the default value is 100 for all types of Search requests.No
pageSize
Integer
The number of results per page.
If a value is not assigned to this parameter, by default, all of the results will be displayed on one page.
No
currentPage
Integer
This value indicates a specific page of the displayed results. The default value is 1. For example, if the pageSize is set to 5 (5 results per page) and the current page is set to 2 (the second page of results), result numbers 6-10 would be returned.No

Response

Polygon Search Response Fields

Response FieldDescription
polygon
Polygon
This is the polygon to search (This is only returned if a polygon was given).
locations
Location[]
This is three or more location nodes that make up the request's polygon (This is only returned if locations was given).

Search Response Fields

Response FieldDescription
infoThis field contains information about the response.

The statusCode subfield is an integer return value. Refer to the status codes page for more details on our status codes and error messages.

The messages subfield is an array of error messages which describe the status.
ambiguities
Boolean
This will return true or false if ambiguities could be returned.
units
String
Specifies the type of units to use when calculating distance. Acceptable values are:
  • m - Miles
  • k - Kilometers
  • wmin - Walking Minutes
  • dmin - Drive Minutes
  • dm - Drive Miles
  • dk - Drive Drive Minutes
Default value is "m"
maxMatches
Integer
Maximum amount of results to return.
shapeFormat
String
These shapeFormats are also described in more detail on the Geometry page. Shape format options:
  • raw - shape is represented as float pairs
  • cmp - shape is represented as a compressed path string with 5 digits of precision
  • cmp6 - Same as for cmp, but uses 6 digits of precision.
  • simple - WKT standard for Simple Features.
See the Compressed Lat/Lng description page for more detail, including sample source code and an interactive encoder/decoder.
See the Simple Features Wiki description page for more detail.
currentPage
Integer
The current page of results.
pageSize
Integer
If a page size was set on the request, this is the number of results to return per page in the request.
remoteData
RemoteData
A list of remote data to search against
hostedData
HostedData
A list of hosted data sources to search against
resultsCount
Integer
The number of total results found, this includes the cached paged items.
searchResult
SearchResult
The results of the search request. Refer below to the SearchResult object documentation for details.

Example Request

POST https://www.mapquestapi.com/search/v2/polygon?key=KEY

Example Request Body

JSON
{
    "polygon": [
        40.078811,
        -76.730422,
        41.078811,
        -74.730422,
        40.078811,
        -74.730422,
        39.961879,
        -76.730422,
        39.961879,
        -76.730422,
        40.078811,
        -76.730422
    ],
    "options": {
        "maxMatches": 4
    }
}
XML
<search>
    <polygon>
        <latLng>
            <lat>40.078811</lat>
            <lng>-76.730422</lng>
        </latLng>
        <latLng>
            <lat>41.078811</lat>
            <lng>-74.730422</lng>
        </latLng>
        <latLng>
            <lat>40.078811</lat>
            <lng>-74.730422</lng>
        </latLng>
        <latLng>
            <lat>39.961879</lat>
            <lng>-76.730422</lng>
        </latLng>
        <latLng>
            <lat>39.961879</lat>
            <lng>-76.730422</lng>
        </latLng>
        <latLng>
            <lat>40.078811</lat>
            <lng>-76.730422</lng>
        </latLng>
    </polygon>
    <options>
        <maxMatches>4</maxMatches>
    </options>
</search>

Example Response

JSON
{
  "polygon": {
    "exterior": [
      40.078811,
      -76.730422,
      41.078811,
      -74.730422,
      40.078811,
      -74.730422,
      39.961879,
      -76.730422,
      39.961879,
      -76.730422,
      40.078811,
      -76.730422
    ]
  },
  "searchResults": [
    {
      "resultNumber": 1,
      "distance": 0,
      "sourceName": "mqap.ntpois",
      "name": "Dr. David D'Angelo & Dr. Renee D'Angelo",
      "shapePoints": [
        40.322799,
        -75.061206
      ],
      "distanceUnit": "m",
      "key": "ea52556d-9456-47aa-bca6-cecff9d3f019",
      "fields": {
        "phone": "2158626363",
        "side_of_street": "L",
        "group_sic_code": "809907",
        "state": "PA",
        "lng": -75.061206,
        "group_sic_code_name": "Health Services",
        "city": "Buckingham",
        "country": "US",
        "group_sic_code_name_ext": "Health Services::Alternative Medicine",
        "id": "290451916",
        "mqap_geography": {
          "latLng": {
            "lng": -75.061206,
            "lat": 40.322799
          }
        },
        "address": "4814 York Rd",
        "postal_code": "18912",
        "name": "Dr. David D'Angelo & Dr. Renee D'Angelo",
        "mqap_id": "ea52556d-9456-47aa-bca6-cecff9d3f019",
        "group_sic_code_ext": "809907::804946",
        "disp_lat": 40.322579,
        "lat": 40.322799,
        "disp_lng": -75.060845
      }
    },
    {
      "resultNumber": 2,
      "distance": 0,
      "sourceName": "mqap.ntpois",
      "name": "Anderson Tax & Bookkeeping Service",
      "shapePoints": [
        39.974323,
        -76.678675
      ],
      "distanceUnit": "m",
      "key": "1589d52b-a514-4ec0-a34e-75c08dc98a0d",
      "fields": {
        "phone": "7176599732",
        "side_of_street": "R",
        "group_sic_code": "872101",
        "state": "PA",
        "lng": -76.678675,
        "group_sic_code_name": "Accountants",
        "city": "York",
        "country": "US",
        "group_sic_code_name_ext": "Accountants::Accounting & Bookkeeping General Svc",
        "id": "273492680",
        "mqap_geography": {
          "latLng": {
            "lng": -76.678675,
            "lat": 39.974323
          }
        },
        "address": "2460 E Market St",
        "postal_code": "17402",
        "name": "Anderson Tax & Bookkeeping Service",
        "mqap_id": "1589d52b-a514-4ec0-a34e-75c08dc98a0d",
        "group_sic_code_ext": "872101::872102",
        "disp_lat": 39.974323,
        "lat": 39.974323,
        "disp_lng": -76.678675
      }
    },
    {
      "resultNumber": 3,
      "distance": 0,
      "sourceName": "mqap.ntpois",
      "name": "D S C Logistics",
      "shapePoints": [
        40.567149,
        -75.622408
      ],
      "distanceUnit": "m",
      "key": "998badfd-3ba4-4a14-9bfc-fe5f4bd7ac5b",
      "fields": {
        "phone": "4846647059",
        "side_of_street": "L",
        "group_sic_code": "874201",
        "state": "PA",
        "lng": -75.622408,
        "group_sic_code_name": "Business Management Consultants",
        "city": "Breinigsville",
        "country": "US",
        "group_sic_code_name_ext": "Business Management Consultants",
        "id": "42068783",
        "mqap_geography": {
          "latLng": {
            "lng": -75.622408,
            "lat": 40.567149
          }
        },
        "address": "250 Boulder Dr",
        "postal_code": "18031",
        "name": "D S C Logistics",
        "mqap_id": "998badfd-3ba4-4a14-9bfc-fe5f4bd7ac5b",
        "group_sic_code_ext": "874201",
        "disp_lat": 40.567149,
        "lat": 40.567149,
        "disp_lng": -75.622408
      }
    },
    {
      "resultNumber": 4,
      "distance": 0,
      "sourceName": "mqap.ntpois",
      "name": "Home Sewing Center",
      "shapePoints": [
        40.578242,
        -75.476315
      ],
      "distanceUnit": "m",
      "key": "284411d9-57f8-4b8d-86b7-319de4826dbc",
      "fields": {
        "phone": "6107972107",
        "side_of_street": "R",
        "group_sic_code": "572218",
        "state": "PA",
        "lng": -75.476315,
        "group_sic_code_name": "Sewing Machines-Household",
        "city": "Allentown",
        "country": "US",
        "group_sic_code_name_ext": "Sewing Machines-Household::Sewing Machines-Repairing",
        "id": "273492671",
        "mqap_geography": {
          "latLng": {
            "lng": -75.476315,
            "lat": 40.578242
          }
        },
        "address": "1901 S 12th St",
        "postal_code": "18103",
        "name": "Home Sewing Center",
        "mqap_id": "284411d9-57f8-4b8d-86b7-319de4826dbc",
        "group_sic_code_ext": "572218::769925",
        "disp_lat": 40.578242,
        "lat": 40.578242,
        "disp_lng": -75.476315
      }
    }
  ],
  "resultsCount": 4,
  "hostedData": [
    {
      "tableName": "mqap.ntpois",
      "extraCriteria": "",
      "columnNames": []
    }
  ],
  "totalPages": 1,
  "info": {
    "statusCode": 0,
    "copyright": {
      "text": "© 2023 MapQuest, Inc.",
      "imageUrl": "https://api.mqcdn.com/res/mqlogo.gif",
      "imageAltText": "© 2023 MapQuest, Inc."
    },
    "messages": []
  },
  "options": {
    "kmlStyleUrl": "http://www.search.mapquestapi.com/kml-default.kml",
    "shapeFormat": "raw",
    "ambiguities": true,
    "pageSize": 4,
    "currentPage": 1,
    "units": "m",
    "maxMatches": 4
  }
}
XML
<?xml version="1.0" encoding="UTF-8"?>
<response>
    <info>
        <statusCode>0</statusCode>
        <messages/>
        <copyright>
            <imageUrl>https://api.mqcdn.com/res/mqlogo.gif</imageUrl>
            <imageAltText>© 2023 MapQuest, Inc.</imageAltText>
            <text>© 2023 MapQuest, Inc.</text>
        </copyright>
    </info>
    <search>
        <options>
            <maxMatches>4</maxMatches>
            <units>m</units>
            <shapeFormat>raw</shapeFormat>
            <kmlStyleUrl>http://www.search.mapquestapi.com/kml-default.kml</kmlStyleUrl>
            <currentPage>1</currentPage>
            <pageSize>4</pageSize>
            <ambiguities>true</ambiguities>
        </options>
        <resultsCount>4</resultsCount>
        <totalPages>1</totalPages>
        <hostedDataList>
            <hostedData>
                <tableName>mqap.ntpois</tableName>
                <columnNames/>
            </hostedData>
        </hostedDataList>
        <searchResults>
            <searchResult>
                <key>ea52556d-9456-47aa-bca6-cecff9d3f019</key>
                <name>Dr. David D'Angelo &amp; Dr. Renee D'Angelo</name>
                <resultNumber>1</resultNumber>
                <distance>0.0</distance>
                <distanceUnit>m</distanceUnit>
                <sourceName>mqap.ntpois</sourceName>
                <shapePoints type="point">
                    <latLng>
                        <lat>40.322799</lat>
                        <lng>-75.061206</lng>
                    </latLng>
                </shapePoints>
                <fields>
                    <phone>2158626363</phone>
                    <side_of_street>L</side_of_street>
                    <group_sic_code>809907</group_sic_code>
                    <state>PA</state>
                    <lng>-75.061206</lng>
                    <group_sic_code_name>Health Services</group_sic_code_name>
                    <city>Buckingham</city>
                    <country>US</country>
                    <group_sic_code_name_ext>Health Services::Alternative Medicine</group_sic_code_name_ext>
                    <id>290451916</id>
                    <mqap_geography>POINT (-75.061206 40.322799)</mqap_geography>
                    <address>4814 York Rd</address>
                    <group_sic_code_ext>809907::804946</group_sic_code_ext>
                    <mqap_id>ea52556d-9456-47aa-bca6-cecff9d3f019</mqap_id>
                    <name>Dr. David D'Angelo &amp; Dr. Renee D'Angelo</name>
                    <postal_code>18912</postal_code>
                    <disp_lat>40.322579</disp_lat>
                    <lat>40.322799</lat>
                    <disp_lng>-75.060845</disp_lng>
                </fields>
            </searchResult>
            <searchResult>
                <key>1589d52b-a514-4ec0-a34e-75c08dc98a0d</key>
                <name>Anderson Tax &amp; Bookkeeping Service</name>
                <resultNumber>2</resultNumber>
                <distance>0.0</distance>
                <distanceUnit>m</distanceUnit>
                <sourceName>mqap.ntpois</sourceName>
                <shapePoints type="point">
                    <latLng>
                        <lat>39.974323</lat>
                        <lng>-76.678675</lng>
                    </latLng>
                </shapePoints>
                <fields>
                    <phone>7176599732</phone>
                    <side_of_street>R</side_of_street>
                    <group_sic_code>872101</group_sic_code>
                    <state>PA</state>
                    <lng>-76.678675</lng>
                    <group_sic_code_name>Accountants</group_sic_code_name>
                    <city>York</city>
                    <country>US</country>
                    <group_sic_code_name_ext>Accountants::Accounting &amp; Bookkeeping General Svc</group_sic_code_name_ext>
                    <id>273492680</id>
                    <mqap_geography>POINT (-76.678675 39.974323)</mqap_geography>
                    <address>2460 E Market St</address>
                    <group_sic_code_ext>872101::872102</group_sic_code_ext>
                    <mqap_id>1589d52b-a514-4ec0-a34e-75c08dc98a0d</mqap_id>
                    <name>Anderson Tax &amp; Bookkeeping Service</name>
                    <postal_code>17402</postal_code>
                    <disp_lat>39.974323</disp_lat>
                    <lat>39.974323</lat>
                    <disp_lng>-76.678675</disp_lng>
                </fields>
            </searchResult>
            <searchResult>
                <key>998badfd-3ba4-4a14-9bfc-fe5f4bd7ac5b</key>
                <name>D S C Logistics</name>
                <resultNumber>3</resultNumber>
                <distance>0.0</distance>
                <distanceUnit>m</distanceUnit>
                <sourceName>mqap.ntpois</sourceName>
                <shapePoints type="point">
                    <latLng>
                        <lat>40.567149</lat>
                        <lng>-75.622408</lng>
                    </latLng>
                </shapePoints>
                <fields>
                    <phone>4846647059</phone>
                    <side_of_street>L</side_of_street>
                    <group_sic_code>874201</group_sic_code>
                    <state>PA</state>
                    <lng>-75.622408</lng>
                    <group_sic_code_name>Business Management Consultants</group_sic_code_name>
                    <city>Breinigsville</city>
                    <country>US</country>
                    <group_sic_code_name_ext>Business Management Consultants</group_sic_code_name_ext>
                    <id>42068783</id>
                    <mqap_geography>POINT (-75.622408 40.567149)</mqap_geography>
                    <address>250 Boulder Dr</address>
                    <group_sic_code_ext>874201</group_sic_code_ext>
                    <mqap_id>998badfd-3ba4-4a14-9bfc-fe5f4bd7ac5b</mqap_id>
                    <name>D S C Logistics</name>
                    <postal_code>18031</postal_code>
                    <disp_lat>40.567149</disp_lat>
                    <lat>40.567149</lat>
                    <disp_lng>-75.622408</disp_lng>
                </fields>
            </searchResult>
            <searchResult>
                <key>284411d9-57f8-4b8d-86b7-319de4826dbc</key>
                <name>Home Sewing Center</name>
                <resultNumber>4</resultNumber>
                <distance>0.0</distance>
                <distanceUnit>m</distanceUnit>
                <sourceName>mqap.ntpois</sourceName>
                <shapePoints type="point">
                    <latLng>
                        <lat>40.578242</lat>
                        <lng>-75.476315</lng>
                    </latLng>
                </shapePoints>
                <fields>
                    <phone>6107972107</phone>
                    <side_of_street>R</side_of_street>
                    <group_sic_code>572218</group_sic_code>
                    <state>PA</state>
                    <lng>-75.476315</lng>
                    <group_sic_code_name>Sewing Machines-Household</group_sic_code_name>
                    <city>Allentown</city>
                    <country>US</country>
                    <group_sic_code_name_ext>Sewing Machines-Household::Sewing Machines-Repairing</group_sic_code_name_ext>
                    <id>273492671</id>
                    <mqap_geography>POINT (-75.476315 40.578242)</mqap_geography>
                    <address>1901 S 12th St</address>
                    <group_sic_code_ext>572218::769925</group_sic_code_ext>
                    <mqap_id>284411d9-57f8-4b8d-86b7-319de4826dbc</mqap_id>
                    <name>Home Sewing Center</name>
                    <postal_code>18103</postal_code>
                    <disp_lat>40.578242</disp_lat>
                    <lat>40.578242</lat>
                    <disp_lng>-75.476315</disp_lng>
                </fields>
            </searchResult>
        </searchResults>
        <polygon type="polygon">
            <exterior type="linestring">
                <latLng>
                    <lat>40.078811</lat>
                    <lng>-76.730422</lng>
                </latLng>
                <latLng>
                    <lat>41.078811</lat>
                    <lng>-74.730422</lng>
                </latLng>
                <latLng>
                    <lat>40.078811</lat>
                    <lng>-74.730422</lng>
                </latLng>
                <latLng>
                    <lat>39.961879</lat>
                    <lng>-76.730422</lng>
                </latLng>
                <latLng>
                    <lat>39.961879</lat>
                    <lng>-76.730422</lng>
                </latLng>
                <latLng>
                    <lat>40.078811</lat>
                    <lng>-76.730422</lng>
                </latLng>
            </exterior>
        </polygon>
    </search>
</response>