Set the zoom at a specific lon and altitute on a MapView

Hi,

I am trying to zoom in the plot of the Netherlands at a specific lon and altitute. But I could not find anything to do this. Is this possible and if so how?

So from this:

to something like this:

Regards,
Jip

Hello Jip,

If you would like to open a map at a specific location, you could add a point by coordinates. Probably you only want to do this until you add more features to the map. So you could do something like this:

@MapView("Map view", duration_guess=1)
def get_map_view(self, params, *args, **kwargs):
   features = []
   coord_x, coord_y = "Enter your x-coord here", "Enter you y-coord here"
      
   if not features:
      features.append(MapPoint(coord_x, coord_y))

   return MapResult(features)

Does this answer your question?

Hi Jelle,

This helped a lot, but if the map is allready loaded. The zoom in doesn’t work. Is there than some other option to do this?

kind regards jip

Hi Jip,

Im not sure what you mean by if the map is already loaded. Could you elaborate on this?
If you always want to keep the zoom you could remove the if-statement “if not features”.

@MapView("Map view", duration_guess=1)
def get_map_view(self, params, *args, **kwargs):
   features = []
   coord_x, coord_y = "Enter your x-coord here", "Enter you y-coord here"
      
   features.append(MapPoint(coord_x, coord_y))

   return MapResult(features)

Hi Jelle,

First I make a map by page(… views: [get_map_view]) with an empty features list. Then I got the lon and lat of the place that needs to be zoomed in. So simple coded below. But now it only makes an pointer on the location, but do not zoom in. I make the page in the parametrization

def get_map_view(self, params, *args, **kwargs):
   features = []
   coord_x, coord_y = "Enter your x-coord here", "Enter you y-coord here"
   if zoom:
        features.append(MapPoint(coord_x, coord_y))

   return MapResult(features)

If you use the three dots on the right corner and select the center map, the map will zoom on the MapPoint!
But to have a function to automatically auto-center the map could be handy.

1 Like

Hi @Jelle is this possible?

Kind Regards,
Jip Ridderbos

Hi @jip.ridderbos,

Currently this is not possible. The current workaround is as suggested by @sonomirco (thank you for you response!), by centering to location by clicking on the three dots.

I do agree this would be a nice feature, I added a request on a list with requested new map features. This list will be considered for a future map view update.

1 Like

I have changed this to a feature request, after hearing of more requests of this feature.

Requested by:

@frisodam and Kent H.

1 Like