Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minNativeZoom and maxNativeZoom #389

Open
2 of 8 tasks
nawalnew opened this issue May 8, 2019 · 14 comments
Open
2 of 8 tasks

minNativeZoom and maxNativeZoom #389

nawalnew opened this issue May 8, 2019 · 14 comments
Labels
bug confirmed Issue is accepted as either a bug or a valid enhancement help wanted

Comments

@nawalnew
Copy link

nawalnew commented May 8, 2019

Description

I need to set a different minZoom for mobile devices. "minNativeZoom" is not working with Vue2Leaflet. Any advices?

Steps to Reproduce

Because at zomm level 3 the map shows Gray Borders left and right I had to do minZoom to 3.5.

On Mobile I need at least minZoom 2.0.

Ive ried the minNativeZoom in the options, but no success.

Expected Results

When setting minNativeZoom to 2 it should be more visible map on mobile

Actual Results

No Effect.

Browsers Affected

  • Chrome

  • Firefox

  • Edge

  • Safari 9

  • Safari 8

  • IE 11

  • Chrome Mobile

  • Safari Mobile

@DonNicoJs
Copy link
Member

@nawalnew Could you show a piece of the code on how you are passing minNativeZoom to the component ?

@nawalnew
Copy link
Author

nawalnew commented May 8, 2019

@nawalnew Could you show a piece of the code on how you are passing minNativeZoom to the component ?

@DonNicoJs Thanks for reply.
I hope this helps.

Ive tried it in "l-map" options too. Both no effect

<l-map style="height: 100%" :zoom="zoom" :center="center" @update:zoom="zoomUpdated" :options="mapOptions"
      @update:center="centerUpdated"
      @update:bounds="boundsUpdated" :bounds="bounds" :max-bounds="maxBounds">
      <l-tile-layer :url="url" :attribution="attribution" :options="tileOptions"></l-tile-layer>
      <l-marker
        v-for="marker in markers"
        :key="marker.id"
        :visible="marker.visible"
        :draggable="marker.draggable"
        :lat-lng.sync="marker.position"
        :icon="marker.icon"
      >
      <l-popup :content="marker.popup" />
        <!-- <l-tooltip :content="marker.tooltip" /> -->
      </l-marker>
    </l-map>
import { latLngBounds, latLng, icon } from "leaflet";
import {LMap, LTileLayer, LMarker, LTooltip, LPopup } from 'vue2-leaflet';

export default {
    name: 'Map',
    components: {
        LMap,
        LTileLayer,
        LMarker,
        LTooltip,
        LPopup
    },
    async mounted () {
        this.$nextTick(() => {
          // this.$refs.layer.mapObject = 6
          // // set the level your need, and should ≦ the max level of source
        })
      },
    data() {
      return {
        zoom:3.5,
        mapOptions: {
          zoomSnap: 0.25,
          zoomDelta: 0.25,
        },
        tileOptions: {
          maxZoom: 6, 
          minZoom: 3.5,
          minNativeZoom: 1,
          zoom:3.5, 
          detectRetina: true,
          updateWhenIdle: false, 
          keepBuffer: 10
        },
        center: L.latLng(54.413220, -36.219482),
        url:'./static/tiles/{z}/{x}/{y}.png',
        attribution:'&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors',
        marker: L.latLng(47.413220, -1.219482),
        markers: [
        {
          id: "m1",
          position: { lat: 52.470, lng: -7.62 },
          popup: "<div class='marker-popup'><p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr,<br> sed diam nonumy eirmod tempor invidunt ut labore et dolore magna </p><button class='marker-btn'>Start</button></div>",
          tooltip: "Tooltip",
          draggable: false,
          visible: true,
          icon: L.icon({
            iconUrl: 'static/marker-icon.png',
            iconRetinaUrl: 'static/marker-icon-2x.png',
            iconSize: [32, 53]
          }),
        }
      ],
        bounds: latLngBounds([
        [85.03637495102464,149.6430587768555],
        [-35.515598503911704,-180.04737854003906]
      ]),
      maxBounds: latLngBounds([
        [85.03637495102464,149.6430587768555],
        [-35.515598503911704,-180.04737854003906]
      ]),
      maxBoundsViscosity: 0.2,

      }
    },
    methods: {
    zoomUpdated (zoom) {
      this.zoom = zoom;
    },

    centerUpdated (center) {
      this.center = center;
    },
    boundsUpdated (bounds) {
      this.bounds = bounds;
    }
  }
}

@DonNicoJs
Copy link
Member

@nawalnew thanks for the code, will investigate this soon.

@stale
Copy link

stale bot commented Jan 1, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jan 1, 2020
@DonNicoJs DonNicoJs added confirmed Issue is accepted as either a bug or a valid enhancement and removed wontfix labels Jan 1, 2020
@greenaerotech
Copy link

I'm having issues getting maxNativeZoom to be a recognized/passed parameter in Vue2Leaflet l-tile-layer object also. Seems to pass maxZoom without problem, but not maxNativeZoom.

@lights0123
Copy link

lights0123 commented Apr 20, 2020

I had no issues with:

<l-tile-layer
	:url="url"
	:attribution="attribution"
	:options="{ maxNativeZoom: 18, maxZoom: 100 }"
/>

And then setting maxZoom as an option on the <l-map> (the high value of maxZoom in the tile layer is ignored if the map's setting is lower)

@bradley-varol
Copy link

I had no issues with:

<l-tile-layer
	:url="url"
	:attribution="attribution"
	:options="{ maxNativeZoom: 18, maxZoom: 100 }"
/>

And then setting maxZoom as an option on the <l-map> (the high value of maxZoom in the tile layer is ignored if the map's setting is lower)

When using these settings, the tiles disappear (grey screen) for me when zooming past the default maximum...

@cristobalcl
Copy link

I'm also blocking by this and I would like to give it a try and work in a PR, but I'm very new to Vue so any help or direction would be great. Any idea about where should I look? LMap.vue? optionsMerge?

@cristobalcl
Copy link

Ok, not a bug at all.

I move minZoom, maxZoom, and maxNativeZoom to the LTileLayerComponent options and everything started to work. You need to move those three parameters because if you put only maxNativeZoom you will experience weird zoom behavior.

To be clear: maxNativeZoom is an option of the layer not of the map. The rest of the zoom parameters are also valid in the map component though.

@christopherritter
Copy link

minZoom, maxZoom, and maxNativeZoom

I've included these three settings in LTileLayerComponent but it's still showing a gray map above 18. I've also included minZoom and maxZoom on the l-map without any luck.

@Abdu2105
Copy link

what are news to issue above

@Mayki00
Copy link

Mayki00 commented Aug 5, 2022

Hi @christopherritter and @cristobalcl,

Were you able to find a solution to use maxNativeZoom with Vue2Leaflet ?

thanks in advance

@cristobalcl
Copy link

Hello @Mayki00, yes, as I said in my previous message the solution for me was to move that configuration inside the layer configuration (LTileLayerComponent), NOT in the map configuration. I hope this makes sense :)

@Mayki00
Copy link

Mayki00 commented Aug 6, 2022

Perfect, thank you, it works for me now ;-)

<l-tile-layer :url="mapTileUrl" :attribution="mapAttribution" :tile-size="tileSize" :options="mapOptions" ></l-tile-layer>

with mapOptions :

mapOptions: { zoom: 15, minZoom: 3, maxZoom: 25, maxNativeZoom: 18, zoomOffset: -1, },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug confirmed Issue is accepted as either a bug or a valid enhancement help wanted
Projects
None yet
Development

No branches or pull requests

9 participants