(mapJSONObj, level = 22)
| 101 | */ |
| 102 | |
| 103 | export function viewOptionsFromMapJSON(mapJSONObj, level = 22) { |
| 104 | let { bounds, dpi, center, visibleScales, scale, coordUnit, prjCoordSys, scaleDenominators, resolutions } = mapJSONObj; |
| 105 | const mapCenter = |
| 106 | center.x && center.y ? [center.x, center.y] : [(bounds.left + bounds.right) / 2, (bounds.bottom + bounds.top) / 2]; |
| 107 | const extent = [bounds.left, bounds.bottom, bounds.right, bounds.top]; |
| 108 | let projection = Util.getProjection(prjCoordSys, extent); |
| 109 | resolutions = resolutions || Util.scalesToResolutions(visibleScales, bounds, dpi, coordUnit, level); |
| 110 | const resolution = scaleDenominators ? (1.0 / scale) : Util.scaleToResolution(scale, dpi, coordUnit); |
| 111 | const zoom = Util.getZoomByResolution(resolution, resolutions); |
| 112 | return { |
| 113 | center: mapCenter, |
| 114 | projection, |
| 115 | zoom, |
| 116 | resolutions |
| 117 | }; |
| 118 | } |
| 119 | |
| 120 | function createMap(result, mapOptions, viewOptions) { |
| 121 | let view = viewOptionsFromMapJSON(result); |
no outgoing calls
no test coverage detected