perliedman / leaflet-control-geocoder

A simple geocoder form to locate places. Easily extended to multiple data providers.
http://www.liedman.net/leaflet-control-geocoder/
BSD 2-Clause "Simplified" License
564 stars 221 forks source link

Changing the default zoom of map #345

Open ragavendra opened 8 months ago

ragavendra commented 8 months ago

hi,

Like asked in stack overflow here

I would like to change the default zoom setting of the map.

The default leaflet zoom setting for leaflet is as below.

var center_ = [0, 0];
var map = L.map('map', {
  center: center_,
  zoom: 16
});

L.Control.geocoder().addTo(map);
Jack-Leey commented 8 months ago

geocoder.options.geocoder.reverse(e.latlng, map.getZoom(), function(results){ console.log(results[0].name); }); Why is the output always the country name regardless of the value of Zoom!! Here is a reference: https://wiki.openstreetmap.org/wiki/Zh-hans:Nominatim

Jack-Leey commented 8 months ago

geocoder.options.geocoder.reverse(e.latlng, map.getZoom(), function(results){ console.log(results[0].name);为什么输出始终是国家/地区名称,而不管 Zoom 的值如何!!这是一个参考:https://wiki.openstreetmap.org/wiki/Zh-hans:Nominatim

ok!! i know how to solve the problem: replace "map. options. crs. scale (map. getZoom())" to solve it!