How to use leaflet-control-geocoder - 7 common examples

To help you get started, we’ve selected a few leaflet-control-geocoder examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nextzen / nextzen.js / src / js / components / routing.js View on Github external
geocoder: function (key, options) {
    var params = APIKeyCheck.getKeyAndOptions(key, options);
    return new MapzenControlGeocoder.class(params.key, params.options); // eslint-disable-line
  },
github nextzen / nextzen.js / src / js / components / controlGeocoder.js View on Github external
module.exports.controlGeocoder = function (key, options) {
  var params = APIKeyCheck.getKeyAndOptions(key, options);
  if (!APIKeyCheck.isValidMapzenApiKey(params.key)) {
    APIKeyCheck.throwApiKeyWarning('Search');
  }
  return new MapzenControlGeocoder.class(params.key, params.options); // eslint-disable-line
};
github Project-OSRM / osrm-frontend / index.js View on Github external
return L.icon({
      iconUrl: markerList[1],
      iconSize: [20, 56],
      iconAnchor: [10, 28]
    });
  } else {
    return L.icon({
      iconUrl: url,
      iconSize: [20, 56],
      iconAnchor: [10, 28]
    });
  }
}

var plan = new ReversablePlan([], {
  geocoder: Geocoder.nominatim(),
  routeWhileDragging: true,
  createMarker: function(i, wp, n) {
    var options = {
      draggable: this.draggableWaypoints,
      icon: makeIcon(i, n)
    };
    var marker = L.marker(wp.latLng, options);
    marker.on('click', function() {
        plan.spliceWaypoints(i, 1);
    });
    return marker;
  },
  routeDragInterval: 100,
  addWaypoints: true,
  waypointMode: 'snap',
  position: 'topright',
github Project-OSRM / osrm-frontend / src / index.js View on Github external
return L.icon({
      iconUrl: markerList[1],
      iconSize: [20, 56],
      iconAnchor: [10, 28]
    });
  } else {
    return L.icon({
      iconUrl: url,
      iconSize: [20, 56],
      iconAnchor: [10, 28]
    });
  }
}

var plan = new ReversablePlan([], {
  geocoder: Geocoder.nominatim(),
  routeWhileDragging: true,
  createMarker: function(i, wp, n) {
    var options = {
      draggable: this.draggableWaypoints,
      icon: makeIcon(i, n)
    };
    var marker = L.marker(wp.latLng, options);
    marker.on('click', function() {
      plan.spliceWaypoints(i, 1);
    });
    return marker;
  },
  routeDragInterval: options.lrm.routeDragInterval,
  addWaypoints: true,
  waypointMode: 'snap',
  position: 'topright',
github Stellarium / stellarium-web-engine / web-frontend / src / components / location-mgr.vue View on Github external
this.$nextTick(() => {
      let map = this.$refs.myMap.mapObject
      var geocoder = new L.Control.Geocoder({
        defaultMarkGeocode: false, position: 'topleft'
      }).on('markgeocode', function (e) {
        var pos = { lat: e.geocode.center.lat, lng: e.geocode.center.lng }
        that.mapCenter = [ pos.lat, pos.lng ]
        pos.accuracy = 100
        var loc = {
          short_name: (pos.accuracy > 500 ? 'Near ' : '') + 'Lat ' + pos.lat.toFixed(3) + '° Lon ' + pos.lng.toFixed(3) + '°',
          country: 'Unknown',
          lng: pos.lng,
          lat: pos.lat,
          alt: pos.alt ? pos.alt : 0,
          accuracy: pos.accuracy,
          street_address: ''
        }
        let res = e.geocode.properties
        let city = res.address.city ? res.address.city : (res.address.village ? res.address.village : res.name)
github mapcontrib / mapcontrib / public / js / view / geocodeWidget.js View on Github external
_buildGeocoder() {
    const lang = document.l10n.supportedLocales[0];
    const bounds = this._radio.reqres.request('map:currentBounds');
    const left = bounds._southWest.lng;
    const top = bounds._northEast.lat;
    const right = bounds._northEast.lng;
    const bottom = bounds._southWest.lat;
    const { lat, lng } = this._radio.reqres.request('map:currentCenter');

    switch (this.model.get('geocoder')) {
      case CONST.geocoder.nominatim:
        return leafletControlGeocoder.nominatim({
          geocodingQueryParams: {
            viewbox: `${left},${top},${right},${bottom}`,
            'accept-language': lang
          }
        });
      default:
        return leafletControlGeocoder.photon({
          geocodingQueryParams: {
            lat,
            lon: lng,
            lang
          }
        });
    }
  }
});
github mapcontrib / mapcontrib / public / js / view / geocodeWidget.js View on Github external
const left = bounds._southWest.lng;
    const top = bounds._northEast.lat;
    const right = bounds._northEast.lng;
    const bottom = bounds._southWest.lat;
    const { lat, lng } = this._radio.reqres.request('map:currentCenter');

    switch (this.model.get('geocoder')) {
      case CONST.geocoder.nominatim:
        return leafletControlGeocoder.nominatim({
          geocodingQueryParams: {
            viewbox: `${left},${top},${right},${bottom}`,
            'accept-language': lang
          }
        });
      default:
        return leafletControlGeocoder.photon({
          geocodingQueryParams: {
            lat,
            lon: lng,
            lang
          }
        });
    }
  }
});

leaflet-control-geocoder

Extendable geocoder with builtin support for OpenStreetMap Nominatim, Bing, Google, Mapbox, MapQuest, What3Words, Photon, Pelias, HERE, Neutrino, Plus codes

BSD-2-Clause
Latest version published 2 years ago

Package Health Score

57 / 100
Full package analysis