當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript proj.transformExtent函數代碼示例

本文整理匯總了TypeScript中ol/proj.transformExtent函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript transformExtent函數的具體用法?TypeScript transformExtent怎麽用?TypeScript transformExtent使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了transformExtent函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: extentWrapped

export function extentWrapped(map: ol.Map, extent: Extent) {
  // Return an extent that's wrapped so that it follows the camera as it pans across a looping map.
  let extentWgs = OLProj.transformExtent(extent, WEB_MERCATOR, WGS84)
  const centroid = [
    (extentWgs[0] + extentWgs[2]) / 2,
    (extentWgs[1] + extentWgs[3]) / 2,
  ] as Point

  const wrapIndex = getWrapIndex(map, centroid)
  extentWgs[0] += wrapIndex * 360
  extentWgs[2] += wrapIndex * 360

  return OLProj.transformExtent(extentWgs, WGS84, WEB_MERCATOR)
}
開發者ID:venicegeo,項目名稱:bf-ui,代碼行數:14,代碼來源:geometries.ts

示例2: Error

    map.once('postcompose', (event: ol.render.Event) => {
      const canvas = event.context.canvas
      const imageData = event.context.getImageData(0, 0, canvas.width, canvas.height)
      const newCanvas = document.createElement('canvas')
      const context = newCanvas.getContext('2d')
      if (!context) {
        throw new Error('Could not get context!')
      }

      newCanvas.width = canvas.width
      newCanvas.height = canvas.height
      context.putImageData(imageData, 0, 0)

      const extent = map.getView().calculateExtent(map.getSize())
      const transformedExtent = proj.transformExtent(extent, 'EPSG:3857', 'EPSG:4326')
      const truncatedExtent = transformedExtent.map(n => n.toFixed(2))

      context.fillStyle = 'white'
      context.fillRect(0, newCanvas.height - 50, newCanvas.width, 50)
      context.font = '12pt monospace'
      context.fillStyle = 'black'
      context.textAlign = 'left'
      context.fillText(timestamp, 10, (newCanvas.height - 20))
      context.textAlign = 'right'
      context.fillText('Viewport: ' + truncatedExtent, newCanvas.width - 10, (newCanvas.height - 20))
      hyperlink.href = newCanvas.toDataURL()
    })
開發者ID:venicegeo,項目名稱:bf-ui,代碼行數:27,代碼來源:openlayers.ExportControl.ts

示例3: calculateExtent

export function calculateExtent(geometry: OLGeometry) {
  if (geometry instanceof OLMultiPolygon && crossesMeridian(geometry)) {
    const extents = geometry.getPolygons().map(g => OLProj.transformExtent(g.getExtent(), WEB_MERCATOR, WGS84))
    let [, minY, , maxY] = OLProj.transformExtent(geometry.getExtent(), WEB_MERCATOR, WGS84)
    let width = 0
    let minX = 180

    for (const [polygonMinX, , polygonMaxX] of extents) {
      width += polygonMaxX - polygonMinX

      if (polygonMaxX > 0) {
        minX -= polygonMaxX - polygonMinX
      }
    }

    return OLProj.transformExtent([minX, minY, minX + width, maxY], WGS84, WEB_MERCATOR)
  }

  return geometry.getExtent()  // Use as-is
}
開發者ID:venicegeo,項目名稱:bf-ui,代碼行數:20,代碼來源:geometries.ts

示例4: serializeBbox

export function serializeBbox(extent: Extent) {
  const bbox = OLProj.transformExtent(extent, WEB_MERCATOR, WGS84)
  const p1 = bbox.slice(0, 2)
  const p2 = bbox.slice(2, 4)
  return p1.concat(p2).map(truncate) as Extent
}
開發者ID:venicegeo,項目名稱:bf-ui,代碼行數:6,代碼來源:geometries.ts

示例5: deserializeBbox

export function deserializeBbox(serialized: Extent | null) {
  if (serialized && serialized.length === 4) {
    return OLProj.transformExtent(serialized, WGS84, WEB_MERCATOR)
  }
  return null
}
開發者ID:venicegeo,項目名稱:bf-ui,代碼行數:6,代碼來源:geometries.ts

示例6: crossesMeridian

export function crossesMeridian(geometry: OLGeometry) {
  const [minX, , maxX] = OLProj.transformExtent(geometry.getExtent(), WEB_MERCATOR, WGS84)
  return minX === -180 && maxX === 180
}
開發者ID:venicegeo,項目名稱:bf-ui,代碼行數:4,代碼來源:geometries.ts

示例7:

 const extents = geometry.getPolygons().map(g => OLProj.transformExtent(g.getExtent(), WEB_MERCATOR, WGS84))
開發者ID:venicegeo,項目名稱:bf-ui,代碼行數:1,代碼來源:geometries.ts


注:本文中的ol/proj.transformExtent函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。