[GIS] Leaflet-Search plugin error

leaflet

I try to connect Leaflet search plugin to my map with GeoJSON data. But when I enter a search query in browser inspector I get error: layer.getBounds is not a function in leaflet-search.js. You can see it on http://ignn.ru/test/ (try to input "Volgograd" or "Alaska")

var searchControl = new L.Control.Search({
        layer: ggg,
        propertyName: 'name',
        marker: false,
        moveToLocation: function(latlng, title, map) {
            //map.fitBounds( latlng.layer.getBounds() );
            var zoom = map.getBoundsZoom(latlng.layer.getBounds());
            map.setView(latlng, zoom); // access the zoom
        }
    });
map.addControl( searchControl );

I did this on example http://labs.easyblog.it/maps/leaflet-search/examples/geojson-layer.html

ggg: layer with geojson data

I understand because of this error the reason that do not give you any search results.

GeoJSON data – http://ignn.ru/test/test.js

Update:
In data there is a single object of type point. When I remove it, everything works. But I need the elements of type point.

Best Answer

Here I load the search control, define the layer to search, the field to search, and then just use setView to zoom to the point. I set the zoom to 12 for grins. Since it's a point, I just set the zoom for all my points the same.

http://www.gistechsolutions.com/leaflet/DEMO/baseball/Baseball2.html

    var searchControl = new L.Control.Search({
    layer: bbTeam,
    propertyName: 'Name',
    marker: false,
    moveToLocation: function(latlng) {
        map.setView(latlng, 12); // set the zoom
    }
});
Related Question