GeoSearch
Simple nodejs library to find places all around the world
Datasource: Mapy.cz Suggest API
Demo
https://stackblitz.com/edit/geosearch
Install
via yarn
yarn add @coex/geosearch
via npm
npm install @coex/geosearch
Usage
City, town, village
Let's find all Springfields in the World
import { GeoSearch } from '@coex/geosearch';
const geoSearch = new GeoSearch();
geoSearch
.suggest('Springfield', {
scope: 'muni',
})
.then((places) => {
console.log('Results', places);
})
.catch((e) => {
console.error('Error', e);
});
Places start with
Let's find cities or villages start with Ber in Germany
import { GeoSearch } from '@coex/geosearch';
const geoSearch = new GeoSearch();
geoSearch
.suggest('Ber', {
scope: 'muni',
country: 'de',
})
.then((places) => {
console.log('Results', places);
})
.catch((e) => {
console.error('Error', e);
});
Public transport
Let's find position of public transport station in the Czech Republic
import { GeoSearch } from '@coex/geosearch';
const geoSearch = new GeoSearch();
geoSearch
.suggest('kokořín', {
scope: 'pubt',
country: 'cz',
})
.then((places) => {
console.log('Results', places);
})
.catch((e) => {
console.error('Error', e);
});
More!
Let's try to find rivers, lakes, mountains, streets, national parks, areas, tourist attractions, ..., everything what awesome Mapy.cz Suggest API can do.
Results (example)
[
{
category: 'municipality_cz',
highlight: [],
sentence: '',
userData: {
bbox: [Array],
country: 'Česko',
district: 'Hlavní město Praha',
elasticWeight: 0,
evidenceNumber: '',
hasAddress: true,
highlight: [Array],
highlightSecond: [Array],
houseNumber: '',
iconType: 'geo',
id: 3468,
img: '',
importance: 0.763394835100681,
latitude: 50.0835493857,
longitude: 14.4341412988,
mmid: '',
mmsource: '',
mmtype: '',
muniId: '3468',
municipality: 'Praha',
nuts: 'CZ0100',
poiType: '',
poiTypeId: 0,
popularity: 1,
premiseIds: [],
quarter: '',
region: 'Hlavní město Praha',
source: 'muni',
street: '',
streetNumber: '',
suggestFirstRow: 'Praha',
suggestSecondRow: 'okres Hlavní město Praha, kraj Hlavní město Praha, Česko',
suggestThirdRow: 'Hlavní město',
ward: '',
wikiId: 'Q1085',
zipCode: '',
},
},
];
Options
Option | Type | Default | Description |
---|
scope | 'muni' | 'area' | 'pubt' | 'street' | null | Preferred category of results |
bounds | { sw: LatLng, ne: LatLng} | null | Preffered country boundaries |
country | 'cz' | 'sk' | 'us' | 'de' | null | Preferred country (same as bounds but with some presets) |
debug | boolean | false | Print additional information to console |
Development
Developing and debugging library
yarn start
Run demo locally
You can find and modify it in demo/index.ts
file
yarn demo
Run tests
yarn test
License
Data source
Awesome Mapy.cz Suggest API from Seznam.cz
Please read this license before use.
This library
Code of this library is licensed under the MIT license.
© 2021 COEX