Skip to content

how to set custom zoom into map when location found #346

Open

Description

@marketdevsoft

Hi,
i need to change default map-zoom level of search result.
I try with this code but doesn't work :

        .on('markgeocode', function(e) {
            map.setZoomAround(e.geocode.bbox.getCenter(), 10);
        }) 

Can someone help me?

Activity

  1. analoghifi commented on Oct 9, 2024

    @analoghifi

    I have the same problem

  2. analoghifi commented on Oct 18, 2024

    @analoghifi

    in the meantime found a workaround for me:

    var initial_zoom = 17;
    .
    .
    var map = L.map('map', mapOptions);
    .
    .
    var myGeocoder = L.Control.geocoder(geoCoderOptions).addTo(map);
    .
    .
    myGeocoder.on('markgeocode', function(e) {
    	map.setZoom(initial_zoom, {animate: false});
    });
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions