Sha256: 1087f63548e34af6eab6355f68840cd7277e91f56bfdac872bb54454132166f5

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

/**
 * L.Control.GeoSearch - search for an address and zoom to it's location
 * L.GeoSearch.Provider.Bing uses bing geocoding service
 * https://github.com/smeijer/leaflet.control.geosearch
 */

L.GeoSearch.Provider.Bing = L.Class.extend({
	options: {

	},

	initialize: function (options) {
		options = L.Util.setOptions(this, options);
	},

	GetServiceUrl: function (qry) {
		var parameters = L.Util.extend({
			query: qry,
			jsonp: '?'
		}, this.options);

		return 'http://dev.virtualearth.net/REST/v1/Locations'
			+ L.Util.getParamString(parameters);
	},

	ParseJSON: function (data) {
		if (data.resourceSets.length == 0 || data.resourceSets[0].resources.length == 0)
			return [];

		var results = [];
		for (var i = 0; i < data.resourceSets[0].resources.length; i++)
			results.push(new L.GeoSearch.Result(
				data.resourceSets[0].resources[i].point.coordinates[1],
				data.resourceSets[0].resources[i].point.coordinates[0],
				data.resourceSets[0].resources[i].address.formattedAddress
			));

		return results;
	}
});

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
leaflet-geosearch-rails-0.4.0 vendor/assets/javascripts/leaflet.geosearch.provider.bing.js