簡體   English   中英

帶有自定義圖像的脫機映射:如何將圖像居中並使其填滿屏幕

[英]Offline mapping with custom image: How to center image and make it fill up the screen

我想制作一個可以全屏平移和縮放圖像的應用程序。 標記將顯示有關圖像那部分的信息。 這很像一張地圖。 因此,我開始使用Phonegap和OpenLayers離線映射。 現在我已經成功實現了這一點,但是我似乎並沒有抓住坐標系。 當我在Android上運行應用程序時,它會顯示黑屏,直到我觸摸縮放控件。 然后一下子就可以看到該圖像了,您可以將其拖動並瀏覽。 我認為這與坐標系有關。

這是我的init函數,基本上可以顯示地圖並使其正常工作:我正在尋找一種方法來使我的圖像居中並在運行此應用時使其充滿整個屏幕。

var init = function () {
// create map
map = new OpenLayers.Map({
    div: "map",
    theme: null,

    // komt van http://trac.osgeo.org/openlayers/wiki/UsingCustomTiles
    maxExtent: new OpenLayers.Bounds(  0.0, -3433.0, 3433.0, 0.0 ),
    maxResolution: 16.000000,
    numZoomLevels: 7,
    // end

    controls: [
        new OpenLayers.Control.Attribution(),
        new OpenLayers.Control.TouchNavigation({
            dragPanOptions: {
                enableKinetic: true
            }
        }),
        new OpenLayers.Control.Zoom()
    ],
    layers: [
        new OpenLayers.Layer.TMS( "TMS Layer","",
                {  url: '', serviceVersion: '.', layername: '.', alpha: false,
                    type: 'jpg', getURL: overlay_getTileURL,
                    transitionEffect: 'resize'
                })
    ],
    center: new OpenLayers.LonLat(1000, 1000),
    zoom: 3
});
};

這是一個非常常見的問題-您需要map.zoomToMaxExtent(); 在您的init函數末尾。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM