leaflet-search-geocoder.js 951 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. (function (factory) {
  2. if(typeof define === 'function' && define.amd) {
  3. //AMD
  4. define(['leaflet'], factory);
  5. } else if(typeof module !== 'undefined') {
  6. // Node/CommonJS
  7. module.exports = factory(require('leaflet'));
  8. } else {
  9. // Browser globals
  10. if(typeof window.L === 'undefined')
  11. throw 'Leaflet must be loaded first';
  12. factory(window.L);
  13. }
  14. })(function (L) {
  15. L.Control.Search.include({
  16. options: {
  17. geocoder: 'google',
  18. markerLocation: true,
  19. autoType: false,
  20. autoCollapse: true,
  21. minLength: 2
  22. },
  23. /* onAdd: function (map) {
  24. L.Control.Search.prototype.onAdd.call(this, map);
  25. console.log('Geocoder',this.options)
  26. },*/
  27. geocoders: {
  28. /* 'google': {
  29. url: "//maps.googleapis.com/maps/api/geocode/json?key={key}&address={text}"
  30. },
  31. 'nominatim': {
  32. format: 'json',
  33. q: query,
  34. });
  35. "//nominatim.openstreetmap.org/search?"
  36. }*/
  37. }
  38. });
  39. });