|
| 1 | +# georaster-layer-for-leaflet |
| 2 | + |
| 3 | +Muestre GeoTIFF en su mapa de LeafletJS |
| 4 | + |
| 5 | +## Install |
| 6 | + |
| 7 | +```bash |
| 8 | +npm install georaster-layer-for-leaflet |
| 9 | +``` |
| 10 | + |
| 11 | +## GeoRaster Requisitos |
| 12 | + |
| 13 | +GeoRasterLayer requiere que su datos convertido en la forma de GeoRaster. |
| 14 | +Su instala GeoRaster por esta: |
| 15 | +```bash |
| 16 | +npm install georaster |
| 17 | +``` |
| 18 | + |
| 19 | +## Instala via `<script/>` |
| 20 | + |
| 21 | +```html |
| 22 | +<script src="https://unpkg.com/georaster-layer-for-leaflet/dist/georaster-layer-for-leaflet.min.js"> |
| 23 | +``` |
| 24 | +
|
| 25 | +## Uso |
| 26 | +
|
| 27 | +```javascript |
| 28 | +new GeoRasterLayer({ georaster }).addTo(map); |
| 29 | +``` |
| 30 | +
|
| 31 | +## Demos |
| 32 | +
|
| 33 | +- <https://geotiff.github.io/georaster-layer-for-leaflet-example/> |
| 34 | +- <https://geotiff.github.io/georaster-layer-for-leaflet-example/examples/load-file.html> |
| 35 | +- Más Aquí: <https://github.com/GeoTIFF/georaster-layer-for-leaflet-example> |
| 36 | +
|
| 37 | +## El Propósito |
| 38 | +
|
| 39 | +- La mayoría de las proyecciones funciona a causo de [proj4-fully-loaded](https://github.com/danieljdufour/proj4-fully-loaded) y [epsg.io](https://epsg.io/) |
| 40 | +- Visualización súper rápida a causo de a una interpolación de vecino más cercano |
| 41 | +- Use WebWorkers para que el "main thread" no esté bloqueado |
| 42 | +- LVisualice 100MB+ GeoTIFF |
| 43 | +- Representación personalizada que incluye colores personalizados, flechas direccionales y dibujo de contexto |
| 44 | +- No requiere WebGL |
| 45 | +
|
| 46 | +## The GeoRasterLayer Class |
| 47 | +
|
| 48 | +Una clase personalizada para representar GeoTIFF (incluidos los COG) en un mapa de LeafletJS. La capa extiende L.GridLayer, consulte los [docs](https://leafletjs.com/reference-1.7.1.html#gridlayer) para conocer las opciones y los métodos heredados. |
| 49 | +
|
| 50 | +### Uno Ejemplo |
| 51 | +
|
| 52 | +Source Code: <https://github.com/GeoTIFF/georaster-layer-for-leaflet-example/blob/master/main.js> |
| 53 | +
|
| 54 | +```javascript |
| 55 | +var parse_georaster = require("georaster"); |
| 56 | +
|
| 57 | +var GeoRasterLayer = require("georaster-layer-for-leaflet"); |
| 58 | +
|
| 59 | +// empieze el mapa de LeafletJS |
| 60 | +var map = L.map('map').setView([0, 0], 5); |
| 61 | +
|
| 62 | +// incluye datos de OpenStreetMap |
| 63 | +L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { |
| 64 | + attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors' |
| 65 | +}).addTo(map); |
| 66 | +
|
| 67 | +var url_to_geotiff_file = "example_4326.tif"; |
| 68 | +
|
| 69 | +fetch(url_to_geotiff_file) |
| 70 | + .then(response => response.arrayBuffer()) |
| 71 | + .then(arrayBuffer => { |
| 72 | + parse_georaster(arrayBuffer).then(georaster => { |
| 73 | + console.log("georaster:", georaster); |
| 74 | +
|
| 75 | + /* |
| 76 | + GeoRasterLayer es una extensión de GridLayer, |
| 77 | + lo que significa que se puede usar opciones de GridLayer como la opacidad. |
| 78 | +
|
| 79 | + Necesito incluir la opción georaster! |
| 80 | +
|
| 81 | + Opcionalmente, use la función pixelValuesToColorFn para cambiar |
| 82 | + cómo los valores de un píxel se traducen a un color. |
| 83 | +
|
| 84 | + http://leafletjs.com/reference-1.2.0.html#gridlayer |
| 85 | + */ |
| 86 | + var layer = new GeoRasterLayer({ |
| 87 | + georaster: georaster, |
| 88 | + opacity: 0.7, |
| 89 | + pixelValuesToColorFn: values => values[0] === 42 ? '#ffffff' : '#000000', |
| 90 | + resolution: 64 // parámetro opcional para ajustar la resolución de la pantalla |
| 91 | + }); |
| 92 | + layer.addTo(map); |
| 93 | +
|
| 94 | + map.fitBounds(layer.getBounds()); |
| 95 | +
|
| 96 | + }); |
| 97 | +}); |
| 98 | +``` |
| 99 | +
|
| 100 | +<!-- ## Options --> |
| 101 | +<!-- todo: add a table of options for GeoRasterLayer --> |
| 102 | +
|
| 103 | +### Métodos |
| 104 | +
|
| 105 | +| Método | Resulto | Descripción | |
| 106 | +| ------------------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 107 | +| updateColors(pixelValuesToColorFn, options) | this | Hace que las fichas se vuelvan a dibujar sin borrarlas primero. Utiliza la función `pixelValuesToColorFn`. Se puede usa un debugLevel específico para esta función pasando un objeto de opciones con una propiedad debugLevel. Por ejemplo, puede activar las depuraciones de la consola para este método configurando `debugLevel = 1` en las opciones. | | |
| 108 | +
|
| 109 | +## Capacidades Avanzadas |
| 110 | +
|
| 111 | +Lea acerca de nuestras capacidades avanzadas, incluidas las funciones de dibujo de contexto personalizadas y la visualización de flechas direccionales en [ADVANCED.md](ADVANCED.md). |
| 112 | +
|
| 113 | +## Más Preguntas |
| 114 | +
|
| 115 | +Lee esto: [Frequently Asked Questions](FAQs.md) |
| 116 | +
|
| 117 | +## Videos |
| 118 | +- [Edge Compute: Cool Stuff You Can Do With COGs in the Browser](https://www.youtube.com/watch?v=XTkNhGpfmB8&t=4190s) |
| 119 | +- [2019 - Algorithm Walk-through: How to Visualize a Large GeoTIFF on Your Web Map](https://www.youtube.com/watch?v=K47JvCL99w0) |
| 120 | +
|
| 121 | +## Ayuda |
| 122 | +
|
| 123 | +Envia un correo electrónico al autor, [email protected] |
0 commit comments