1/** 2 * @fileOverview 3 * ÐÑÐ¸Ð¼ÐµÑ ÑеализаÑии ÑÑнкÑионалÑноÑÑи множеÑÑвенного геокодиÑованиÑ. 4 * ÐналогиÑÐ½Ð°Ñ ÑазÑабоÑка Ð´Ð»Ñ Ð¿ÐµÑвой веÑÑии ÐÐÐ. 5 * @see http://api.yandex.ru/maps/doc/jsapi/1.x/examples/multiplygeocoding.html 6 * @example 7 * var multiGeocoder = new MultiGeocoder({ boundedBy : map.getBounds() }); 8 * multiGeocoder 9 * .geocode(['ÐоÑква, ÐÑва ТолÑÑого 16', [55.7, 37.5], 'СанкÑ-ÐеÑеÑбÑÑг']) 10 * .then( 11 * function (res) { 12 * map.geoObjects.add(res.geoObjects); 13 * }, 14 * function (err) { 15 * console.log(err); 16 * } 17 * ); 18 */ 19 20/** 21 * ÐлаÑÑ Ð´Ð»Ñ Ð³ÐµÐ¾ÐºÐ¾Ð´Ð¸ÑÐ¾Ð²Ð°Ð½Ð¸Ñ ÑпиÑка адÑеÑов или кооÑдинаÑ. 22 * @class 23 * @name MultiGeocoder 24 * @param {Object} [options={}] ÐеÑолÑнÑе опÑии мÑлÑÑигеокодеÑа. 25 */ 26function MultiGeocoder(options) { 27 this._options = options || {}; 28} 29 30/** 31 * ФÑнкÑÐ¸Ñ Ð¼Ð½Ð¾Ð¶ÐµÑÑвеннеого геокодиÑованиÑ. 32 * @function 33 * @requires ymaps.util.extend 34 * @see http://api.yandex.ru/maps/doc/jsapi/2.x/ref/reference/util.extend.xml 35 * @requires ymaps.util.Promise 36 * @see http://api.yandex.ru/maps/doc/jsapi/2.x/ref/reference/util.Promise.xml 37 * @name MultiGeocoder.geocode 38 * @param {Array} requests ÐаÑÑив ÑÑÑок-имен Ñопонимов и/или геомеÑÑий ÑоÑек (обÑаÑное геокодиÑование) 39 * @returns {Object} Ðак и в обÑÑном геокодеÑе, веÑнем обÑекÑ-обеÑание. 40 */ 41MultiGeocoder.prototype.geocode = function (requests, options) { 42 var self = this, 43 opts = ymaps.util.extend({}, self._options, options), 44 size = requests.length, 45 promise = new ymaps.util.Promise(), 46 result = [], 47 geoObjects = new ymaps.GeoObjectArray(); 48 49 requests.forEach(function (request, index) { 50 ymaps.geocode(request, opts) 51 .then( 52 function (response) { 53 var geoObject = response.geoObjects.get(0); 54 55 geoObject && (result[index] = geoObject); 56 --size || (result.forEach(geoObjects.add, geoObjects), promise.resolve({ geoObjects : geoObjects })); 57 }, 58 function (err) { 59 promise.reject(err); 60 } 61 ); 62 }); 63 64 return promise; 65}; 66
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.