Types and interfaces

Types of interfaces used in the constructors, options and functions of the Geocoding Control library.

ProximityRule

A proximity rule is used to give a higher priority to the Geocoding search results. The closer to the proximity point the higher the priority. The rule determines a geographic point with which the coordinates of the elements of the search result are compared.

Regardless of the type of rule, each proximity rule can have defined maximum and minimum zoom levels where that rule is applied. The zoom level is obtained from the map view. This only applies if you are using the Geocoding Control with a JS map library like MapTiler SDK, Leaflet, MapLibre, or OpenLayers.

Example of a fixed proximity rule that only applies between zoom levels 14 and 18.

Types of ProximityRule

fixed

The proximity point is defined by fixed point at specific coordinates [lng, lat].

Example: to prioritize results that are near Times Square in New York

map-center

The map view center coordinates define the proximity point. This only applies if you are using the Geocoding Control with a JS map library like MapTiler SDK, Leaflet, MapLibre, or OpenLayers.

server-geolocation

This is the default option. The proximity point is defined using server-side IP geolocation from the Geocoding API call.

client-geolocation

Use the browser’s geolocation API for define the proximity point. If it fails, following proximity rules are iterated.

Example: cached the results for 5 minutes

Usage

You can apply a single rule or combine multiple rules to improve your user’s search results experience.

Example of applying multiple rules in combination. First matching rule from the array will be used.

In this case if the zoom level of the map view is greater than 12, use the map-centermap-center option.
If the zoom level is greater than 8 and less than 12 then use the client-geolocation option, if the position cannot be obtained with that option then use the server-geolocation option as a fallback.