Giter Site home page Giter Site logo

Comments (5)

abkfenris avatar abkfenris commented on July 26, 2024 1

I've got a TileWMS layer working, but only supporting the WMS options that I need at this point. TileLayer and TileWMS can be quickly swapped for ImageLayer and ImageWMS if your source doesn't support tiled WMS requests.

import React from "react"
import { RContextType, RLayerRaster, RLayerRasterProps } from "rlayers"
import { toast } from "react-toastify"

import TileLayer from "ol/layer/Tile"
import TileWMS from "ol/source/TileWMS"

// TileWMS options from https://openlayers.org/en/latest/apidoc/module-ol_source_TileWMS-TileWMS.html
export interface RTileWMSLayerProps extends RLayerRasterProps {
  // attributions
  // attributionsCollapsible
  // cacheSize
  // crossOrgin
  // imageSmoothing
  params: { [key: string]: any }
  // gutter
  // hidip
  // projection
  // reprojectionErrorThreshold
  // tileClass
  // tileGrid
  // serverType
  // tileLoadFunction
  url?: string
  //   urls?: [string]
  // wrapX
  // transition
  // zDirection
}

export class RTileWMSLayer extends RLayerRaster<RTileWMSLayerProps> {
  ol: TileLayer
  source: TileWMS

  constructor(
    props: Readonly<RTileWMSLayerProps>,
    context: React.Context<RContextType>
  ) {
    super(props, context)
    this.createSource()
    this.ol = new TileLayer({ source: this.source })
    this.eventSources = [this.ol, this.source]
  }

  createSource(): void {
    const { params, url } = this.props
    const options = { params, url }

    this.source = new TileWMS(options)
    this.eventSources = [this.ol, this.source]
  }

  refresh(prevProps?: RTileWMSLayerProps): void {
    super.refresh(prevProps)
    this.createSource()
  }
}

from rlayers.

mmomtchev avatar mmomtchev commented on July 26, 2024

There is no WMS support at the moment - but it is relatively easy to implement it from the WMTS layer

from rlayers.

dmestudent avatar dmestudent commented on July 26, 2024

Okay thank you for the quick response. I think I will have to build a temp workaround for my case then until it is implemented. I would love to do it myself but I have no knowledge about how I can extend a library that is written in typescript since I have no typescript experience πŸ˜…

from rlayers.

mmomtchev avatar mmomtchev commented on July 26, 2024

You can submit a PR if you wish

from rlayers.

mmomtchev avatar mmomtchev commented on July 26, 2024

rlayers 1.1 has basic TileWMS support

from rlayers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.