Skip to content

Commit b8fd9f5

Browse files
committed
util: export/import individual functions
1 parent 1cfae96 commit b8fd9f5

File tree

11 files changed

+41
-46
lines changed

11 files changed

+41
-46
lines changed

src/geocoders/arcgis.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import L from 'leaflet';
2-
import Util from '../util';
2+
import {getJSON} from '../util';
33

44
export default {
55
class: L.Class.extend({
@@ -25,7 +25,7 @@ export default {
2525
params.token = this._key;
2626
}
2727

28-
Util.getJSON(this.options.service_url + '/findAddressCandidates', params, function(data) {
28+
getJSON(this.options.service_url + '/findAddressCandidates', params, function(data) {
2929
var results = [],
3030
loc,
3131
latLng,
@@ -59,7 +59,7 @@ export default {
5959
f: 'json'
6060
};
6161

62-
Util.getJSON(this.options.service_url + '/reverseGeocode', params, function(data) {
62+
getJSON(this.options.service_url + '/reverseGeocode', params, function(data) {
6363
var result = [],
6464
loc;
6565

src/geocoders/bing.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import L from 'leaflet';
2-
import Util from '../util';
2+
import {jsonp} from '../util';
33

44
export default {
55
class: L.Class.extend({
@@ -8,7 +8,7 @@ export default {
88
},
99

1010
geocode : function (query, cb, context) {
11-
Util.jsonp('https://dev.virtualearth.net/REST/v1/Locations', {
11+
jsonp('https://dev.virtualearth.net/REST/v1/Locations', {
1212
query: query,
1313
key : this.key
1414
}, function(data) {
@@ -29,7 +29,7 @@ export default {
2929
},
3030

3131
reverse: function(location, scale, cb, context) {
32-
Util.jsonp('//dev.virtualearth.net/REST/v1/Locations/' + location.lat + ',' + location.lng, {
32+
jsonp('//dev.virtualearth.net/REST/v1/Locations/' + location.lat + ',' + location.lng, {
3333
key : this.key
3434
}, function(data) {
3535
var results = [];

src/geocoders/google.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import L from 'leaflet';
2-
import Util from '../util';
2+
import {getJSON} from '../util';
33

44
export default {
55
class: L.Class.extend({
@@ -27,7 +27,7 @@ export default {
2727

2828
params = L.Util.extend(params, this.options.geocodingQueryParams);
2929

30-
Util.getJSON(this.options.serviceUrl, params, function(data) {
30+
getJSON(this.options.serviceUrl, params, function(data) {
3131
var results = [],
3232
loc,
3333
latLng,
@@ -59,7 +59,7 @@ export default {
5959
params.key = this._key;
6060
}
6161

62-
Util.getJSON(this.options.serviceUrl, params, function(data) {
62+
getJSON(this.options.serviceUrl, params, function(data) {
6363
var results = [],
6464
loc,
6565
latLng,

src/geocoders/here.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import L from 'leaflet';
2-
import Util from '../util';
2+
import {getJSON} from '../util';
33

44
export default {
55
class: L.Class.extend({
@@ -42,7 +42,7 @@ export default {
4242
},
4343

4444
getJSON: function(url, params, cb, context) {
45-
Util.getJSON(url, params, function(data) {
45+
getJSON(url, params, function(data) {
4646
var results = [],
4747
loc,
4848
latLng,

src/geocoders/mapbox.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import L from 'leaflet';
2-
import Util from '../util';
2+
import {getJSON} from '../util';
33

44
export default {
55
class: L.Class.extend({
@@ -23,7 +23,7 @@ export default {
2323
{
2424
params.proximity = params.proximity.lng + ',' + params.proximity.lat;
2525
}
26-
Util.getJSON(this.options.serviceUrl + encodeURIComponent(query) + '.json', params, function(data) {
26+
getJSON(this.options.serviceUrl + encodeURIComponent(query) + '.json', params, function(data) {
2727
var results = [],
2828
loc,
2929
latLng,
@@ -57,7 +57,7 @@ export default {
5757
},
5858

5959
reverse: function(location, scale, cb, context) {
60-
Util.getJSON(this.options.serviceUrl + encodeURIComponent(location.lng) + ',' + encodeURIComponent(location.lat) + '.json', this.options.reverseQueryParams, function(data) {
60+
getJSON(this.options.serviceUrl + encodeURIComponent(location.lng) + ',' + encodeURIComponent(location.lat) + '.json', this.options.reverseQueryParams, function(data) {
6161
var results = [],
6262
loc,
6363
latLng,

src/geocoders/mapquest.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import L from 'leaflet';
2-
import Util from '../util';
2+
import {getJSON} from '../util';
33

44
export default {
55
class: L.Class.extend({
@@ -28,7 +28,7 @@ export default {
2828
},
2929

3030
geocode: function(query, cb, context) {
31-
Util.getJSON(this.options.serviceUrl + '/address', {
31+
getJSON(this.options.serviceUrl + '/address', {
3232
key: this._key,
3333
location: query,
3434
limit: 5,
@@ -54,7 +54,7 @@ export default {
5454
},
5555

5656
reverse: function(location, scale, cb, context) {
57-
Util.getJSON(this.options.serviceUrl + '/reverse', {
57+
getJSON(this.options.serviceUrl + '/reverse', {
5858
key: this._key,
5959
location: location.lat + ',' + location.lng,
6060
outputFormat: 'json'

src/geocoders/mapzen.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import L from 'leaflet';
2-
import Util from '../util';
2+
import {getJSON} from '../util';
33

44
export default {
55
class: L.Class.extend({
@@ -17,7 +17,7 @@ export default {
1717

1818
geocode: function(query, cb, context) {
1919
var _this = this;
20-
Util.getJSON(this.options.serviceUrl + "/search", L.extend({
20+
getJSON(this.options.serviceUrl + "/search", L.extend({
2121
'api_key': this._apiKey,
2222
'text': query
2323
}, this.options.geocodingQueryParams), function(data) {
@@ -27,7 +27,7 @@ export default {
2727

2828
suggest: function(query, cb, context) {
2929
var _this = this;
30-
Util.getJSON(this.options.serviceUrl + "/autocomplete", L.extend({
30+
getJSON(this.options.serviceUrl + "/autocomplete", L.extend({
3131
'api_key': this._apiKey,
3232
'text': query
3333
}, this.options.geocodingQueryParams), L.bind(function(data) {
@@ -40,7 +40,7 @@ export default {
4040

4141
reverse: function(location, scale, cb, context) {
4242
var _this = this;
43-
Util.getJSON(this.options.serviceUrl + "/reverse", L.extend({
43+
getJSON(this.options.serviceUrl + "/reverse", L.extend({
4444
'api_key': this._apiKey,
4545
'point.lat': location.lat,
4646
'point.lon': location.lng

src/geocoders/nominatim.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import L from 'leaflet';
2-
import Util from '../util';
2+
import {template, getJSON} from '../util';
33

44
export default {
55
class: L.Class.extend({
@@ -24,7 +24,7 @@ export default {
2424
'">{state} {country}</span>');
2525
}
2626

27-
return Util.template(parts.join('<br/>'), a, true);
27+
return template(parts.join('<br/>'), a, true);
2828
}
2929
},
3030

@@ -33,7 +33,7 @@ export default {
3333
},
3434

3535
geocode: function(query, cb, context) {
36-
Util.getJSON(this.options.serviceUrl + 'search', L.extend({
36+
getJSON(this.options.serviceUrl + 'search', L.extend({
3737
q: query,
3838
limit: 5,
3939
format: 'json',
@@ -60,7 +60,7 @@ export default {
6060
},
6161

6262
reverse: function(location, scale, cb, context) {
63-
Util.getJSON(this.options.serviceUrl + 'reverse', L.extend({
63+
getJSON(this.options.serviceUrl + 'reverse', L.extend({
6464
lat: location.lat,
6565
lon: location.lng,
6666
zoom: Math.round(Math.log(scale / 256) / Math.log(2)),

src/geocoders/photon.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import L from 'leaflet';
2-
import Util from '../util';
2+
import {getJSON} from '../util';
33

44
export default {
55
class: L.Class.extend({
@@ -27,7 +27,7 @@ export default {
2727
q: query,
2828
}, this.options.geocodingQueryParams);
2929

30-
Util.getJSON(this.options.serviceUrl, params, L.bind(function(data) {
30+
getJSON(this.options.serviceUrl, params, L.bind(function(data) {
3131
cb.call(context, this._decodeFeatures(data));
3232
}, this));
3333
},
@@ -42,7 +42,7 @@ export default {
4242
lon: latLng.lng
4343
}, this.options.geocodingQueryParams);
4444

45-
Util.getJSON(this.options.reverseUrl, params, L.bind(function(data) {
45+
getJSON(this.options.reverseUrl, params, L.bind(function(data) {
4646
cb.call(context, this._decodeFeatures(data));
4747
}, this));
4848
},

src/geocoders/what3words.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import L from 'leaflet';
2-
import Util from '../util';
2+
import {getJSON} from '../util';
33

44
export default {
55
class: L.Class.extend({
@@ -13,7 +13,7 @@ export default {
1313

1414
geocode: function(query, cb, context) {
1515
//get three words and make a dot based string
16-
Util.getJSON(this.options.serviceUrl +'forward', {
16+
getJSON(this.options.serviceUrl +'forward', {
1717
key: this._accessToken,
1818
addr: query.split(/\s+/).join('.'),
1919
}, function(data) {
@@ -37,7 +37,7 @@ export default {
3737
},
3838

3939
reverse: function(location, scale, cb, context) {
40-
Util.getJSON(this.options.serviceUrl +'reverse', {
40+
getJSON(this.options.serviceUrl +'reverse', {
4141
key: this._accessToken,
4242
coords: [location.lat,location.lng].join(',')
4343
}, function(data) {

0 commit comments

Comments
 (0)