-3

angular(4) アプリケーションに次のコードを実装しようとしました http://viglino.github.io/ol-ext/examples/layer/map.geoimage.html

ただし、ブラウザを起動しようとすると、常にエラーが発生します。

まず、私のインポート (両方のライブラリは npm からローカルにインストールされました):

`

import OlMap from 'ol/map';
import OlView from 'ol/view';
import OlLayerVector from 'ol/layer/vector';
import OlLayerTile from 'ol/layer/Tile';
import OlSourceOSM from 'ol/source/OSM';
import OlLayerImage from 'ol/layer/image';
import OlSourceImageVector from 'ol/source/imagevector';
import OlSourceImageStatic from 'ol/source/ImageStatic';
import OlProjection from 'ol/proj/projection';
import OlSourceVector from 'ol/source/vector';
import OlBaseImage from 'ol/imagebase';
import OlImage from 'ol/image';

import OlSourceGeoImage from 'ol-ext/source/GeoImage';
import OlAttribution from 'ol/attribution';
import OlOverlay from 'ol/overlay';`

以下で使用したコードを見つけてください: (この部分は正しく動作します) `

// OSM tiles as background
    var OSMBackground = new OlLayerTile({
        source: new OlSourceOSM()
    });
// Custom extend used to position my factoryBackgroundLayer image
    var newExtent = OlProj.transformExtent(
        [2.385083, 48.817463, 2.386024, 48.817694],
        "EPSG:4326", "EPSG:3857"
    );


    var factoryBackgroundLayer = new OlLayerImage({
        source: new OlSourceImageStatic({
            url: 'http://viglino.github.io/ol-ext/examples/data/IGNF_PVA_1-0__1976-03-24_pt.jpg',
            // projection: projection,
            // imageExtent: extent
            projection: 'EPSG:27700',
            imageExtent: newExtent
        })
    });


    var map = new OlMap({
        layers: [OSMBackground
            , factoryBackgroundLayer

        ],
        target: 'map',
        view: new OlView({
            center: OlProj.fromLonLat([2.585487, 48.817561]),
            zoom: 20, // Set to 20 is better
        })
    });`

そして、地理参照された画像を表示しようとしました: `

x = 274764.75;
y = 6243935.64;
sx = 0.589;
sy = 0.597;
xmin = 0;
ymin = 0;
xmax = 5526;
ymax = 5000;
rotate = 7.44;
opacity = 0.7;

var geoSource = new OlSourceGeoImage(
        {
            url: 'http://viglino.github.io/ol-ext/examples/data/IGNF_PVA_1-0__1976-03-24_pt.jpg',
            imageCenter: [this.x, this.y],
            imageScale: [this.sx, this.sy],
            imageCrop: [this.xmin, this.ymin, this.xmax, this.ymax],
            imageRotate: this.rotate * Math.PI / 180,
            projection: 'EPSG:27700',
        });


    var geoimg = new OlLayerImage(
        {
            state: "ready",

            opacity: 0.7,
            source: geoSource,
            imageExtent: newExtent
        });

    this.map.addLayer(geoimg);

`

常に同じ問題が発生しました:

エラー TypeError: image.getState は、_ol_renderer_canvas_ImageLayer_.prepareFrame (imagelayer.js:160) の _ol_renderer_canvas_ImageLayer_._ol_renderer_Layer_.loadImage (layer.js:114) の関数ではありません。 renderFrame_ (pluggablemap.js:1180) at _ol_Map_.eval (pluggablemap.js:87) at ZoneDelegate.invokeTask (zone.js:421) at Object.onInvokeTask (core.js:4740) at ZoneDelegate.invokeTask (zone.js: 420) Zone.runTask (zone.js:188) で ZoneTask.invokeTask (zone.js:496) で

このレポートに関しては、url の代わりに ol.source.Image オブジェクトを使用しようとしましたが、うまくいきませんでした。

以前にこのフレームワークを使用したことがある人はいますか? この問題を引き起こした古いアップデートのアイデアはありますか?

PS: SnapGuides の行の例 ( http://viglino.github.io/ol-ext/examples/interaction/map.interaction.snapguides.html ) も試してみましたが、うまくいったので ol-ext API の統合は良さそうです!

4

1 に答える 1