本文整理匯總了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)
}
示例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()
})
示例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
}
示例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
}
示例5: deserializeBbox
export function deserializeBbox(serialized: Extent | null) {
if (serialized && serialized.length === 4) {
return OLProj.transformExtent(serialized, WGS84, WEB_MERCATOR)
}
return null
}
示例6: crossesMeridian
export function crossesMeridian(geometry: OLGeometry) {
const [minX, , maxX] = OLProj.transformExtent(geometry.getExtent(), WEB_MERCATOR, WGS84)
return minX === -180 && maxX === 180
}
示例7:
const extents = geometry.getPolygons().map(g => OLProj.transformExtent(g.getExtent(), WEB_MERCATOR, WGS84))