2

I am use Openlayers to add ArcGIS tilecache layers using arcgiscache class or another way which is jsonp.

I can show the map properly, but when I pan, zoom or drag the map, the tiles seem to jump around, it does not look any good.

Can anybody give me some advice? In this example it has been noticed that a problem the users encounter is that the tiles seem to "jump around", but I do not know how to handle it !

var markers, layer;
var features = [];
var map, baseLayer,
    layerURL = "myurl";

function init() {
    var jsonp = new OpenLayers.Protocol.Script();
    jsonp.createRequest(layerURL, {
        f: 'json',
        pretty: 'true'
    }, initMap);

}
function initMap(layerInfo) {
    baseLayer = new OpenLayers.Layer.ArcGISCache("arciscache", layerURL, {
        layerInfo: layerInfo
    });
    map = new OpenLayers.Map('map', {
        maxExtent: baseLayer.maxExtent,
        units: baseLayer.units,
        resolutions: baseLayer.resolutions,
        numZoomLevels: baseLayer.numZoomLevels,
        tileSize: baseLayer.tileSize,
        eventListeners: { //set event handler
            "moveend": moveEvent}

        //displayProjection: baseLayer.displayProjection
    });

    var zoomControl = map.getControlsByClass('OpenLayers.Control.Zoom')[0];
    map.removeControl(zoomControl);

    map.addLayers([baseLayer]);
    map.addControl(new OpenLayers.Control.MousePosition());

    map.addControl(new OpenLayers.Control.Navigation());
    map.addControl(new OpenLayers.Control.PanZoomBar());
    if (!map.getCenter()) {
        map.zoomToMaxExtent();
    }
}

closed as off-topic by Devdatta Tengshe, Mapperz Aug 6 '14 at 15:42

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Devdatta Tengshe, Mapperz
If this question can be reworded to fit the rules in the help center, please edit the question.

  • What are you trying to so? Please share your code, and let us know in detail what exactly you are experiencing. – Devdatta Tengshe Oct 11 '13 at 8:52
  • function init() { var jsonp = new OpenLayers.Protocol.Script(); jsonp.createRequest(layerURL, { f: 'json', pretty: 'true' }, initMap); } function initMap(layerInfo) { baseLayer = new OpenLayers.Layer.ArcGISCache("基础地图", layerURL, { layerInfo: layerInfo }); map = new OpenLayers.Map('map', { maxExtent: baseLayer.maxExtent, units: baseLayer.units, resolutions: baseLayer.resolutions, numZoomLevels: baseLayer.numZoomLevels, tileSize: baseLayer.tileSize }); – ethel hao Oct 11 '13 at 9:01
  • 1
    Can you transfer your code to your original question, please? The edit button will let you do that and then there is a code button to format it. – PolyGeo Oct 11 '13 at 9:05
  • 1
    @ethelhao: If you compare your code to the code given at : openlayers.org/dev/examples/arcgiscache_ags.html You'll notice that you are initilising the map differently, than given on that page. You are not setting the StartBounds, units, and tileSize correctly. – Devdatta Tengshe Oct 14 '13 at 3:03
  • @Devdatta Tengshe,thanks for your reply,I'll check it now – ethel hao Oct 14 '13 at 3:16
0

I just had the same problem and solved it as follows:

var mapRestrictedExtent = new OpenLayers.Bounds(
  layerInfo.initialExtent.xmin,
  layerInfo.initialExtent.ymin,
  layerInfo.initialExtent.xmax,
  layerInfo.initialExtent.ymax
);

map = new OpenLayers.Map('map', {
  //...
  restrictedExtent: mapRestrictedExtent,
  //...
});

Source (mostly): http://lists.osgeo.org/pipermail/openlayers-users/2011-August/021992.html

Not the answer you're looking for? Browse other questions tagged or ask your own question.