/* COPYRIGHT (C) 2005 HOLZER SOLUTIONS AB. ALL RIGHTS RESERVED. */ var mapDebugMode = false; var mapLateDisplay = false; var mapProduction = true; var fastLoad = false; var flatLoad = true; var notSupportedMessage = "Den hr funktionen kan inte anvndas med din webblsare.\r\n\r\nVi rekommenderar att du anvnder Microsoft Internet Explorer 5 eller senare, Safari 1.2 eller senare, eller Mozilla Firefox."; var isInternetExplorer = (navigator.appName=="Microsoft Internet Explorer"); function mapEnableDebugMode() { mapDebugMode = true; } function asyncNewRequest() { if(window.XMLHttpRequest) { return new XMLHttpRequest(); } try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(x) { try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(xi) { } } alert(notSupportedMessage); return null; } function asyncRunRemoteScript(url, state, notAvailableMessage) { var request = asyncNewRequest(); if(request==null) { return null; } request.open("GET", url, true); request.onreadystatechange = function() { if (request.readyState==4) { asyncComplete(url, request, notAvailableMessage, state); } }; request.send(null); } function asyncComplete(url, request, notAvailableMessage, state) { if(request.status!=200) { if(notAvailableMessage!=null) { alert(notAvailableMessage + "\r\n\r\n" + url + "\r\n" + request.statusText); } return; } eval(request.responseText); if(request.close!=null) request.close(); } function getParent(relative) { if(relative.offsetParent!=null) { return relative.offsetParent; } if(relative.parentElement!=null) { return relative.parentElement; } return relative.parentNode; } function mapPrepare(map, tileSize, zoomIndex, x, y, preloadtiles, scrollPageRatio, scrollSlowdownRatio, zoomLevels, scaleDistances, defaultScrollSteps, tileImageProviderService, boundaryAX, boundaryAY, boundaryBX, boundaryBY, mapName, zoomLock) { map.tileSize = tileSize; map.preloadtiles = preloadtiles; map.mapName = mapName; map.tileImageProviderService = tileImageProviderService; map.tilesToLoad = 0; map.tilesTotal = 0; map.tilesTotalProgress = 0; map.fadeOpacity = 100; map.zoomLock = zoomLock; map.getZoomIndex = function() { return mapGetZoomIndex(this); }; map.tiles = new Array(); map.availableTiles = new Array(); map.leftOffset = 0; map.topOffset = 0; map.useSpan = !isInternetExplorer; map.internalAlignments = 0; map.setCursors = 0; map.urlSets = 0; var port = document.createElement("div"); port.style.position = "absolute"; port.innerHTML = ""; map.appendChild(port); map.port = port; map.overlays = new Array(); map.points = new Array(); map.rectangles = new Array(); map.features = new Array(); map.moving = false; map.moved = false; map.running = false; map.scrolling = false; map.defaultScrollSteps = defaultScrollSteps; map.scrollPageRatio = scrollPageRatio; map.scrollSlowdownRatio = scrollSlowdownRatio; map.scrollIteration = 0; map.areaSelectStep = -1; map.loadingShown = false; map.loadingShowing = false; map.scaleDistances = scaleDistances; map.zoomLevels = zoomLevels; map.zoomIndex = zoomIndex; map.zoomRatio = 1; map.pixelSize = map.zoomLevels[map.zoomIndex]; map.zooming = false; map.mapCenterX = Math.round(x); map.mapCenterY = Math.round(y); map.boundaryAX = boundaryAX; map.boundaryAY = boundaryAY; map.boundaryBX = boundaryBX; map.boundaryBY = boundaryBY; map.oncontextmenu = function() { return true; }; map.ondragstart = function() { return false; }; map.onmousewheel = function(e) { if(!map.zoomLock) { if(e==null) { e = event; } if(e.wheelDelta>0) { mapZoom(map, -1); } else { mapZoom(map, 1); } mapCancelBubble(e); } return false; }; getParent(map).onresize = function() { mapEnforceBoudaries(map, false); mapAlignGeoObjects(map, false, false); }; var scaleControl = document.getElementById(map.id + "__scale"); if(scaleControl!=null && map.scaleDistances.length>0) { map.scale = scaleControl; map.scaleText = document.getElementById(map.id + "__scaletext"); mapUpdateScale(map); } var loadControl = document.getElementById(map.id + "__loading"); if(loadControl!=null) { map.loading = loadControl; map.loading.style.visibility = "hidden"; map.loadingProgress = document.getElementById(loadControl.id + "progress"); } for(var i=0;i=1000 && map.scaleValue%1000==0) { map.scaleText.innerHTML = Math.round(map.scaleValue/1000) + ".0 km"; map.scale.title = "Skallinjal, " + Math.round(map.scaleValue/1000) + ".0 km"; } else { map.scaleText.innerHTML = map.scaleValue + " m"; map.scale.title = "Skallinjal, " + map.scaleValue + " m"; } map.scaleText.style.width = map.scaleValue / map.pixelSize; } } function mapRegisterFeature(map, feature) { map.features.push(feature); } function mapEnforceBoudaries(map, changeCenter) { var parent = getParent(map); var mapX = map.mapCenterX - Math.round(parent.offsetWidth*map.pixelSize/2); if(map.boundaryBX - map.boundaryAX < parent.offsetWidth*map.pixelSize) { mapX = map.boundaryAX + Math.round((map.boundaryBX - map.boundaryAX)/2) - Math.round(parent.offsetWidth*map.pixelSize/2); } else { var violatesAX = mapX < map.boundaryAX; if(violatesAX) { mapX = map.boundaryAX; } var violatesBX = map.boundaryBX < mapX+(parent.offsetWidth*map.pixelSize); if(violatesBX) { mapX = map.boundaryBX - Math.round(parent.offsetWidth*map.pixelSize); } } map.mapX = mapX; var mapY = map.mapCenterY + Math.round(parent.offsetHeight*map.pixelSize/2); if(map.boundaryAY - map.boundaryBY < parent.offsetHeight*map.pixelSize) { mapY = map.boundaryAY + Math.round((map.boundaryBY - map.boundaryAY)/2) + Math.round(parent.offsetHeight*map.pixelSize/2); } else { var violatesAY = mapY > map.boundaryAY; if(violatesAY) { mapY = map.boundaryAY; } var violatesBY = mapY - Math.round(parent.offsetHeight*map.pixelSize) < map.boundaryBY; if(violatesBY) { mapY = map.boundaryBY + Math.round(parent.offsetHeight*map.pixelSize); } } map.mapY = mapY; if(changeCenter && (violatesAX || violatesBX)) { map.mapCenterX = mapX + Math.round(parent.offsetWidth*map.pixelSize/2); } if(changeCenter && (violatesAY || violatesBY)) { map.mapCenterY = mapY - Math.round(parent.offsetHeight*map.pixelSize/2); } return violatesAX || violatesAY || violatesBX || violatesBY; } function mapAlignGeoObjects(map, removeSelection, forceAlignment) { if(removeSelection && document.selection!=null) { document.selection.empty(); } var parent = getParent(map); mapAlignFeatures(map); var preload = 0; var port = map.port; var ps = map.pixelSize/map.zoomRatio; var tsp = map.tileSize*map.zoomRatio; var tsp_ps = tsp*ps; var mxg = map.mapX; var myg = map.mapY; var availableTiles = map.availableTiles; var usespan = map.useSpan; var wp = parent.offsetWidth + 1*preload*tsp; var hp = parent.offsetHeight + 1*preload*tsp; wp = Math.round(wp + tsp - wp % tsp + tsp); hp = Math.round(hp + tsp - hp % tsp + tsp); var xc = wp / tsp; var yc = hp / tsp; var xnp = Math.round( (-mxg/ps) % tsp ) - (preload)*tsp; var xng = Math.round( (mxg + xnp*ps) / tsp_ps) * tsp_ps; var ynp = Math.round( (myg/ps) % tsp ) - tsp; var yng = Math.round( (myg - ynp*ps) / tsp_ps) * tsp_ps; if(isInternetExplorer) { if(port.lastl != xnp) { port.style.posLeft = xnp; port.lastl = xnp; } if(port.lastt != ynp) { port.style.posTop = ynp; port.lastt = ynp; } } else { if(port.lastl != xnp) { port.style.left = xnp + "px"; port.lastl = xnp; } if(port.lastt != ynp) { port.style.top = ynp + "px"; port.lastt = ynp; } } var needsAlignment = (port.lastps!=ps || port.lastw!=wp || port.lasth!=hp || port.lastxng!=xng || port.lastyng!=yng || port.lastmn!=map.mapName); if(needsAlignment) { map.internalAlignments++; port.lastxng = xng; port.lastyng = yng; port.lastps = ps; port.lastmn = map.mapName; if(isInternetExplorer) { if(port.lastw != wp) { port.style.width = wp + "px"; port.lastw = wp; } if(port.lasth != hp) { port.style.height = hp + "px"; port.lasth = hp; } } else { if(port.lastw != wp) { port.style.width = wp + "px"; port.lastw = wp; } if(port.lasth != hp) { port.style.height = hp + "px"; port.lasth = hp; } } var oldTiles = map.tiles; var tiles = new Array(); map.tiles = tiles; var xyc = xc*yc; tiles[xyc-1] = null; map.availableTiles = new Array(); availableTiles = map.availableTiles; for(var i=oldTiles.length-1; i>=0; i--) { var tile = oldTiles[i]; if(tile!=null) { var xt = (tile.xg-xng)/tsp_ps; var yt = (yng-tile.yg)/tsp_ps; if(0<=xt && xt0) { tile = availableTiles.pop(); tile.done = false; } else { map.tilesTotal++; if(usespan) { tile = document.createElement("div"); if(mapDebugMode==false) tile.style.background = "url(Resource.ashx?Request=Holzer.Maps.Presentation.Web.Images.white-" + map.tileSize + ".gif,Holzer.Maps.Presentation.Web)"; } else { tile = document.createElement("img"); tile.galleryImg = false; if(mapDebugMode==false) tile.src = "Resource.ashx?Request=Holzer.Maps.Presentation.Web.Images.white-" + map.tileSize + ".gif,Holzer.Maps.Presentation.Web"; } tile.done = false; tile.loading = false; tile.style.position = "absolute"; tile.style.width = map.tileSize + "px"; tile.style.height = map.tileSize + "px"; tile.onload = function() { var tile = this; if(tile.loading==true) { tile.loading = false; map.tilesToLoad--; if(map.loading!=null) mapUpdateLoadProgress(map); } if(tile.collect==true) { tile.collect = false; } }; port.appendChild(tile); } tiles[tilei] = tile; tile.xg = xng + xt*tsp_ps; tile.yg = yng - yt*tsp_ps; tile.ps = ps; if(isInternetExplorer) { tile.runtimeStyle.display = "block"; } else { tile.style.display = "block"; } if(mapDebugMode) { if(usespan) { tile.innerHTML = tile.xg + "," + tile.yg; } else { tile.alt = yc + " , " + yt + " - " + tile.xg + "," + tile.yg; } } else { tile.alt = "Karta"; var url = map.tileImageProviderService + "/" + map.mapName + "/" + tsp + "," + tsp_ps + "/" + tile.xg + "/" + tile.yg + ".gif"; tile.done = true; var urlChanged = false; if(usespan) { url = "url(" + url + ")"; if(tile.style.background!=url) { map.urlSets++; if(!tile.loading) { tile.loading = true; map.tilesToLoad++; if(map.loading!=null) mapUpdateLoadProgress(map); } tile.style.background = url; urlChanged = true; } } else { if(tile.src!=url) { map.urlSets++; if(!tile.loading) { tile.loading = true; map.tilesToLoad++; if(map.loading!=null) mapUpdateLoadProgress(map); } tile.src = url; urlChanged = true; } } } if(tile.loading) { ttl++; } } } map.tilesToLoad = ttl; for(var xt=0; xttp) { tp = progress; map.tilesTotalProgress = tp; } var r = Math.round((tp-progress)/tp*100); var t = r + "%"; if(isInternetExplorer) { if(t!=map.loadingProgress.runtimeStyle.width) map.loadingProgress.runtimeStyle.width = t; } else { if(t!=map.loadingProgress.style.width) map.loadingProgress.style.width = t; } } } } } function mapLoadProgressDelayedShow(mapid) { var map = document.getElementById(mapid); map.fadeOpacity = 100; map.loading.style.opacity = "1"; map.loading.style.filter = "alpha(opacity=100)"; map.loading.style.visibility = "visible"; map.loadingShown = true; } function mapLoadProgressDelayedClose(mapid) { var map = document.getElementById(mapid); if(map.tilesToLoad==0) { if(map.fadeOpacity <= 0) { map.loading.style.visibility = "hidden"; } else { map.fadeOpacity -= 5; map.loading.style.opacity = map.fadeOpacity/100; map.loading.style.filter = "alpha(opacity=" + map.fadeOpacity + ")"; setTimeout("mapLoadProgressDelayedClose('" + map.id + "')", 25); } } } function mapMoveOnKey(map, e) { var key = e.keyCode; if(key>=37 && key<=40) { mapScrollPage(map, (key-38)%2, (39-key)%2); return false; } else if(key>=187 && key<=189) { mapZoom(map, (188-key)); } else if(key>=107 && key<=109) { mapZoom(map, (108-key)); } else if(key==96) { mapZoom(map, -1); } else if(key>=97 && key<=105) { if(key==101) { mapZoom(map, 1); } else { mapScrollPage(map, ((key-1)%3-1), Math.round((key-101)/3)); } } return true; } function mapMouseMoveStart(map, e) { map.moveX = map.mapX + e.clientX*map.pixelSize; map.moveY = map.mapY - e.clientY*map.pixelSize; map.moveStartX = e.clientX; map.moveStartY = e.clientY; map.moveStart = new Date().getTime(); map.moved = false; map.moving = true; map.moveTracking = new Array(); if(map.setCapture) map.setCapture(); mapMoveTrackingSet(map, e); if(isInternetExplorer) { map.offsetParent.focus(); } } function mapMouseMove(map, e) { var parent = getParent(map); mapSetCursor(map); map.moved = true; if((isInternetExplorer && e.button==0)) { map.moving = false; eval(map.id + "___mapMouseUp(map, e)"); } else { if(map.running==false) { mapMoveTrackingLog(map, e); map.mapCenterX = Math.round(map.moveX - e.clientX*map.pixelSize + parent.offsetWidth*map.pixelSize/2); map.mapCenterY = Math.round(map.moveY + e.clientY*map.pixelSize - parent.offsetHeight*map.pixelSize/2); mapEnforceBoudaries(map, true); mapAlignGeoObjects(map, true, false); } } } function mapMouseMoveStop(map, e, decelerate) { mapEnforceBoudaries(map, true); mapAlignGeoObjects(map, true, false); mapPersistState(map); if(map.moving) { mapMoveTrackingStop(map, e, decelerate); } if(document.releaseCapture) document.releaseCapture(); map.moving = false; } function mapMoveTrackingSet(map, e) { map.moveTrackingStart = new Date().getTime(); map.moveTrackStartX = e.clientX; map.moveTrackStartY = e.clientY; } function mapMoveTrackingLog(map, e) { var usedTime = new Date().getTime() - map.moveTrackingStart; var deltaX = map.moveTrackStartX-e.clientX; var deltaY = map.moveTrackStartY-e.clientY; var scrollDistance = Math.sqrt( Math.pow(deltaX, 2) + Math.pow(deltaY, 2) ); if(usedTime==0) usedTime = 1; var speed = scrollDistance / usedTime; map.moveTracking.push(deltaX); map.moveTracking.push(deltaY); map.moveTracking.push(speed); mapMoveTrackingSet(map, e); } function mapMoveTrackingStop(map, e, decelerate) { if(map.moveTracking.length>6) { map.moveTracking = map.moveTracking.slice(map.moveTracking.length-6); var deltaX = map.moveTracking[0]; var deltaY = map.moveTracking[1]; var speedFactor = Math.min((map.moveTracking[2] + map.moveTracking[5]), 7); if(decelerate) mapScrollDropTo(map, Math.round(map.mapCenterX+deltaX*map.pixelSize*speedFactor), Math.round(map.mapCenterY-deltaY*map.pixelSize*speedFactor), null); } } function mapAverage(a, iS, iT) { var sum = 0; for(i=iS; i0) { point.style.background = "url(" + url + ") no-repeat"; } point.pointBackgroundUrl = url; point.style.position = "absolute"; point.style.zIndex = 100; point.attachX = attachX; point.attachY = attachY; point.clickScript = clickScript; point.onclick = mapPointClick; point.mouseOverScript = mouseOverScript; point.onmouseover = mapPointMouseOver; point.mouseOutScript = mouseOutScript; point.onmouseout = mapPointMouseOut; map.port.appendChild(point); map.points.push(point); if(savePoint) { mapPersistPoints(map); } return point; } function mapCancelBubble(e) { e.cancelBubble = true; if(e.stopPropagation) e.stopPropagation(); } function mapCancelBubbleAndSelection(e) { e.cancelBubble = true; if(e.stopPropagation) e.stopPropagation(); if(document.selection!=null) document.selection.empty(); } function mapPointClick(e) { if(e==null) { e = event; } var point = this; var cancelBubble = true; eval(point.clickScript); if(cancelBubble) { mapCancelBubble(e); } } function mapPointMouseOver(e) { if(e==null) { e = event; } var point = this; var cancelBubble = true; eval(point.mouseOverScript); if(cancelBubble) { mapCancelBubble(e); } } function mapPointMouseOut(e) { if(e==null) { e = event; } var point = this; var cancelBubble = true; eval(point.mouseOutScript); if(cancelBubble) { mapCancelBubble(e); } } function mapClearPoints(map, pointClass) { for(var p=0;p/g, "-,,,,,-"); } function mapAddRectangle(map, ax, ay, bx, by, alt, className, innerText, clickScript, mouseOverScript, mouseOutScript, rectangleClass, saveRectangle) { var rectangle = document.createElement("div"); rectangle.innerHTML = innerText; rectangle.originalInnerHtml = innerText; rectangle.title = alt; rectangle.mapAX = Math.min(ax, bx); rectangle.mapAY = Math.max(ay, by); rectangle.mapBX = Math.max(ax, bx); rectangle.mapBY = Math.min(ay, by); rectangle.className = className; rectangle.rectangleClass = rectangleClass; rectangle.saveRectangle = saveRectangle; rectangle.style.position = "absolute"; rectangle.style.zIndex = 200; rectangle.clickScript = clickScript; rectangle.onclick = mapRectangleClick; rectangle.mouseOverScript = mouseOverScript; rectangle.onmouseover = mapRectangleMouseOver; rectangle.mouseOutScript = mouseOutScript; rectangle.onmouseout = mapRectangleMouseOut; map.port.appendChild(rectangle); map.rectangles.push(rectangle); if(saveRectangle) { mapPersistRectangles(map); } return rectangle; } function mapRectangleClick(e) { if(e==null) { e = event; } var rectangle = this; var cancelBubble = true; eval(rectangle.clickScript); if(cancelBubble) { mapCancelBubble(e); } } function mapRectangleMouseOver(e) { if(e==null) { e = event; } var rectangle = this; var cancelBubble = true; eval(rectangle.mouseOverScript); if(cancelBubble) { mapCancelBubble(e); } } function mapRectangleMouseOut(e) { if(e==null) { e = event; } var rectangle = this; var cancelBubble = true; eval(rectangle.mouseOutScript); if(cancelBubble) { mapCancelBubble(e); } } function mapHasRectangles(map, rectangleClass) { for(var p=0;p/g, "-,,,,,-"); } function mapChangeRectangle(map, rectangle, ax, ay, bx, by) { rectangle.mapAX = Math.min(ax, bx); rectangle.mapAY = Math.max(ay, by); rectangle.mapBX = Math.max(ax, bx); rectangle.mapBY = Math.min(ay, by); if(rectangle.saveRectangle) { mapPersistRectangles(map); } } function mapEncodeString(s) { if(s==null) { return null; } else { return s.replace(/-,-/g, "-,,-"); } } function mapPersistState(map) { var stateContainer = document.getElementById(map.id + "__state"); var state = map.mapCenterX + "-,-" + map.mapCenterY + "-,-" + map.zoomIndex + "-,-" + map.boundaryAX + "-,-" + map.boundaryAY + "-,-" + map.boundaryBX + "-,-" + map.boundaryBY + "-,-" + map.mapName + "-,-"; stateContainer.value = state.replace("\"", "\"\""); } function mapScrollPage(map, x, y, steps) { var parent = getParent(map); if(steps==null) { steps = map.defaultScrollSteps; } map.scrollStartX = map.mapCenterX; map.scrollStartY = map.mapCenterY; map.scrollDistX = x * map.scrollPageRatio * parent.offsetWidth*map.pixelSize; map.scrollDistY = y * map.scrollPageRatio * parent.offsetHeight*map.pixelSize; map.scrollTargetX = map.scrollStartX + map.scrollDistX; map.scrollTargetY = map.scrollStartY + map.scrollDistY; map.scrollSteps = steps; map.scrollStep = 0; mapDoScrollStep(map.id, ++map.scrollIteration); } function mapScrollMap(map, scrollDistX, scrollDistY, steps) { if(steps==null) { steps = map.defaultScrollSteps; } map.scrollStartX = map.mapCenterX; map.scrollStartY = map.mapCenterY; map.scrollDistX = scrollDistX; map.scrollDistY = scrollDistY; map.scrollTargetX = map.scrollStartX + map.scrollDistX; map.scrollTargetY = map.scrollStartY + map.scrollDistY; map.scrollSteps = steps; map.scrollStep = 0; mapDoScrollStep(map.id, ++map.scrollIteration); } function mapScrollMapTo(map, x, y, steps) { if(steps==null) { steps = map.defaultScrollSteps; } map.scrollStartX = map.mapCenterX; map.scrollStartY = map.mapCenterY; map.scrollDistX = x-map.mapCenterX; map.scrollDistY = y-map.mapCenterY; map.scrollTargetX = x; map.scrollTargetY = y; map.scrollSteps = steps; map.scrollStep = 0; mapDoScrollStep(map.id, ++map.scrollIteration); } function mapDoScrollStep(mapid, iteration) { var map = document.getElementById(mapid); if(iteration!=map.scrollIteration) { return; } if(map.scrollStep<=map.scrollSteps) { setTimeout("mapDoScrollStep('" + mapid + "', " + iteration + ")", 30); map.scrollStep++; f = 1 - Math.pow(map.scrollSlowdownRatio, (map.scrollSteps-map.scrollStep)) / Math.pow(map.scrollSlowdownRatio, map.scrollSteps); map.mapCenterX = Math.round(map.scrollStartX + f*map.scrollDistX); map.mapCenterY = Math.round(map.scrollStartY + f*map.scrollDistY); map.scrolling = true; mapEnforceBoudaries(map, false); mapAlignGeoObjects(map, false, false); } else { map.scrollStep++; map.mapCenterX = Math.round(map.scrollTargetX); map.mapCenterY = Math.round(map.scrollTargetY); map.scrolling = false; mapEnforceBoudaries(map, false); mapAlignGeoObjects(map, false, false); mapPersistState(map); } } function mapScrollDropTo(map, x, y, steps) { if(steps==null) { steps = 40; } map.scrollStartX = map.mapCenterX; map.scrollStartY = map.mapCenterY; map.scrollDistX = x-map.mapCenterX; map.scrollDistY = y-map.mapCenterY; map.scrollTargetX = x; map.scrollTargetY = y; map.scrollSteps = steps; map.scrollStep = 0; mapDoScrollStepDrop(map.id, ++map.scrollIteration); } function mapDoScrollStepDrop(mapid, iteration) { var map = document.getElementById(mapid); if(iteration!=map.scrollIteration) { return; } if(map.scrollStep<=map.scrollSteps) { setTimeout("mapDoScrollStepDrop('" + mapid + "', " + iteration + ")", 30); map.scrollStep++; f = 1 - Math.pow(map.scrollSlowdownRatio, (map.scrollSteps-map.scrollStep)) / Math.pow(map.scrollSlowdownRatio, map.scrollSteps); map.mapCenterX = Math.round(map.scrollStartX + f*map.scrollDistX); map.mapCenterY = Math.round(map.scrollStartY + f*map.scrollDistY); map.scrolling = true; mapEnforceBoudaries(map, false); mapAlignGeoObjects(map, false, false); } else { map.scrollStep++; map.mapCenterX = Math.round(map.scrollTargetX); map.mapCenterY = Math.round(map.scrollTargetY); map.scrolling = false; mapEnforceBoudaries(map, false); mapAlignGeoObjects(map, false, false); mapPersistState(map); } } function mapZoom(map, change) { mapZoomTo(map, map.zoomIndex + change); } function mapZoomTo(map, newZoomIndex) { if(map.zoomIndex!=newZoomIndex && newZoomIndex>=0 && newZoomIndex