Learn R Programming

rmapzen (version 0.4.0)

mz_autocomplete: Mapzen search API

Description

Functions to access the various endpoints from the Mapzen Search API. For more details, see https://mapzen.com/documentation/search/. If your data is already split up by street, city, state, zip, etc., then you might find mz_structured_search to be more precise. All arguments besides text (point in the case of mz_reverse_geocode) are optional. If you have parsed addresses (e.g. for geocoding), use mz_structured_search

Usage

mz_autocomplete(text, boundary.country = NULL, boundary.rect = NULL,
  focus.point = NULL, sources = NULL, layers = NULL, api_key = NULL)

mz_reverse_geocode(point, size = NULL, layers = NULL, sources = NULL, boundary.country = NULL, api_key = NULL)

mz_search(text, size = 10, boundary.country = NULL, boundary.rect = NULL, boundary.circle = NULL, focus.point = NULL, sources = NULL, layers = NULL, api_key = NULL)

Arguments

text

Search string

boundary.country

ISO-3166 country code to narrow the search. See mz_countries

boundary.rect

4 corners that define a box to narrow the search. Can be the result of mz_bbox. Should have named elements with names "min_lon", "min_lat", "max_lon", "max_lat" -- can be created using mz_rect.

focus.point

A point to "focus" the search. Can be created with mz_location or mz_geocode, otherwise should have names "lat" and "lon"

sources

The originating source of the data (to filter/narrow search results). See mz_sources

layers

Which layers (types of places) to search. See https://mapzen.com/documentation/search/search/#filter-by-data-type for definitions, and use mz_layers for convenience

api_key

Your Mapzen API key. The default is to look for the key within the provider information that was set up with `mz_set_host`.

point

For reverse geocoding, the location to reverse geocode. Can be created with mz_location or mz_geocode, otherwise should have names "lat" and "lon"

size

Number of search results requested

boundary.circle

A circle to narrow the search. Should have named elements with names "lon", "lat", and "radius"

See Also

mz_place, mz_structured_search, mz_countries, mz_sources, mz_layers

Examples

Run this code
# NOT RUN {
# hard rock cafes in sweden:
mz_search("Hard Rock Cafe", boundary.country = "SE")

# autocompletions when the user types in "Union Square"
# prioritizing San Francisco results first:
mz_autocomplete("Union Square",
                focus.point = mz_geocode("San Francisco, CA"))
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab