tombatossals / angular-leaflet-directive

AngularJS directive to embed an interact with maps managed by Leaflet library
http://tombatossals.github.io/angular-leaflet-directive
MIT License
1.5k stars 635 forks source link

Adding bounds to TileLayer overlay #502

Closed oO closed 9 years ago

oO commented 10 years ago

I can't seem to add bounds to my TileLayer overlay, so I can prevent Leaflet from requesting tiles that don't exists. The examples show how to use bounds for image overlays but not for tile layers.

I've tried bounds using an object with southWest+northEast or with arrays, but I still get requests for invalid tiles. What am I doing wrong?

I'm adding a layers directive with the following data:

{
  "baselayers": {
    "color": {
      "name": "OpenStreetMap (Color)",
      "url": "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
      "type": "xyz",
      "layerOptions": {
        "attribution": "&copy; <a href=\"http://openstreetmap.org\">OpenStreetMap</a> Contributors",
        "maxZoom": 22,
        "maxNativeZoom": 19
      },
      "layerParams": {}
    }
  },
  "overlays": {
    "Expo/F2": {
      "name": "3401 Exposition - Floor 2",
      "type": "xyz",
      "visible": true,
      "url": "/maps/{layerName}/{z}/{x}/{y}.png",
      "bounds": {
        "southWest": {
          "lat": 34.02963355133658,
          "lng": -118.45820009708403
        },
        "northEast": {
          "lat": 34.030627171097336,
          "lng": -118.45708698034286
        }
      },
      "layerParams": {
        "layerName": "Expo/F2"
      },
      "layerOptions": {
        "format": "image/png",
        "transparent": true,
        "minZoom": 17,
        "maxZoom": 23,
        "layerName": "Expo/F2"
      }
    }
  }
}
tombatossals commented 9 years ago

Hi, not really sure to understand your question. The bounds are related to the map coordinate system, not the layer or the overlays. However, things have changed since the last months code addition, take a look at the bounds example:

http://tombatossals.github.io/angular-leaflet-directive/examples/0000-viewer.html#/basic/bounds-example

Please reopen if I didn't understand your question.