dimik / node-multi-geocoder Goto Github PK
View Code? Open in Web Editor NEWNodeJS module for geocoding of address list
License: GNU General Public License v2.0
NodeJS module for geocoding of address list
License: GNU General Public License v2.0
Код:
var MultiGeocoder = require('multi-geocoder'),
geocoder = new MultiGeocoder({ provider: 'yandex-cache', coordorder: 'latlong' });
geocoder.geocode(['Moscow', 'New York', 'Paris', 'London'])
.then(function (res) {
console.log(res);
});
Текст ошибки:
/home/ubuntu/workspace/node_modules/multi-geocoder/lib/providers/yandex/geojson-view.js:17
throw new Error('GeoObject Not Found');
^
Error: GeoObject Not Found
at module.exports.inherit.toGeoJSON (multi-geocoder/lib/providers/yandex/geojson-view.js:17:19)
at module.exports.inherit.process (multi-geocoder/lib/providers/yandex/geocode-provider.js:12:21)
at .<anonymous> (multi-geocoder/lib/providers/base-geocode-provider.js:38:24)
at Request.callback (superagent/lib/node/index.js:591:12)
at superagent/lib/node/index.js:766:18
at Stream.<anonymous> (superagent/lib/node/parsers/json.js:16:7)
at emitNone (events.js:86:13)
at Stream.emit (events.js:185:7)
at Unzip.<anonymous> (superagent/lib/node/utils.js:108:12)
at emitNone (events.js:91:20)
npm audit
=== npm audit security report ===
Manual Review
Some vulnerabilities require your attention to resolve
Visit https://go.npm.me/audit-guide for additional guidance
Low Prototype Pollution
Package lodash
Patched in >=4.17.5
Dependency of multi-geocoder
Path multi-geocoder > lodash
More info https://nodesecurity.io/advisories/577
Low Large gzip Denial of Service
Package superagent
Patched in >=3.7.0
Dependency of multi-geocoder
Path multi-geocoder > superagent
More info https://nodesecurity.io/advisories/479
found 2 low severity vulnerabilities in 34170 scanned packages
2 vulnerabilities require manual review. See the full report for details.
Хотелось бы иметь опцию, чтобы можно было подставить свою библиотеку Промис. Для совместимости с другими модулями.
Я загрузил адресов 1024, а результатов (features.length) получил 1011
В итоге не известно какие адреса пропущены.
При каких обстаятельствах ваш скрипт может пропускать адрес???
Например, Минск, Калинина 1. Яндекс отвечает улица Калинина 1 и переулок Калинина 1.
toGeoJSON
работает только с первым результатом.
Можно конечно просто делать запросы в Яндекс, но очень нравится yandex-cache провайдер
пожалуйста, замените динамическое подключение require('./' + provider + '/geocode-provider');
на явное указаное путей. Иначе после компиляции через browserify выдает ошибку что, модуль не найден
При отработке кода
var getRequestParams = provider.getRequestParams;
provider.getRequestParams = function() {
var result = getRequestParams.apply(provider, arguments);
result.key = process.env.YANDEX_MAPS_API_KEY;
return result;
};
geocoder
.geocode(
[
[myLongitude, myLatitude]
],
{
json: true
}
)
.then(function(res) {
console.log(JSON.stringify(res));
});
Получаю ответ
{"result":{"type":"FeatureCollection","features":[]},"errors":[{"request":[61.79,34.36],"index":0,"reason":"GeoObject Not Found"}]}
Как правильно задать request
строку?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.