[Mapbender-commits] r8044 - in branches/mobile: http/javascripts
http/plugins log
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue Aug 2 08:12:12 EDT 2011
Author: pschmidt
Date: 2011-08-02 05:12:12 -0700 (Tue, 02 Aug 2011)
New Revision: 8044
Added:
branches/mobile/log/mb_error_2011_08_02.log
Removed:
branches/mobile/http/javascripts/MapTouch.js
Modified:
branches/mobile/http/javascripts/mod_box1.js
branches/mobile/http/javascripts/mod_dragMapSize.php
branches/mobile/http/javascripts/mod_featureInfoTunnel.php
branches/mobile/http/javascripts/mod_pan.js
branches/mobile/http/javascripts/mod_selArea.js
branches/mobile/http/javascripts/requestGeometryConstructor.js
branches/mobile/http/plugins/mb_mobile.js
branches/mobile/http/plugins/mb_overview.js
branches/mobile/http/plugins/mb_overview_mobile.js
Log:
Module f?\195?\188r iPad
Deleted: branches/mobile/http/javascripts/MapTouch.js
===================================================================
--- branches/mobile/http/javascripts/MapTouch.js 2011-08-02 12:00:04 UTC (rev 8043)
+++ branches/mobile/http/javascripts/MapTouch.js 2011-08-02 12:12:12 UTC (rev 8044)
@@ -1,275 +0,0 @@
-var defaultTouch;
-function MapTouch(map, $map, mapDom){
- this.map = map;
- this.$elm = $map;
- this.elm = mapDom;
-
- this.started = false;
- this.startPos = 0, this.stopPos = 0;
- this.timestamp = 0;
- this.dblclick = false;
- this.move = false;
- this.pinch = false;
- this.pinchObj = null;
- this.activ = false;
- defaultTouch = this;
-
- this.activate = function() {
- this.elm.addEventListener("touchstart", defaultTouch.startTouch, true);
- this.elm.addEventListener("touchmove", defaultTouch.moveTouch, true);
- this.elm.addEventListener("touchend", defaultTouch.endTouch, true);
- this.activ = true;
- };
- this.activateTouchstart = function() {
- this.elm.addEventListener("touchstart", defaultTouch.startTouch, true);
- };
- this.activateTouchmove = function() {
- this.elm.addEventListener("touchmove", defaultTouch.moveTouch, true);
- };
- this.activateTouchend = function() {
- this.elm.addEventListener("touchend", defaultTouch.endTouch, true);
- };
- this.setActivate = function() {
- this.activ = true;
- };
-
-
- this.deactivate = function() {
- this.elm.removeEventListener("touchstart", defaultTouch.startTouch, true);
- this.elm.removeEventListener("touchmove", defaultTouch.moveTouch, true);
- this.elm.removeEventListener("touchend", defaultTouch.endTouch, true);
- this.activ = false;
- };
- this.deactivateTouchstart = function() {
- this.elm.removeEventListener("touchstart", defaultTouch.startTouch, true);
- };
- this.deactivateTouchmove = function() {
- this.elm.removeEventListener("touchmove", defaultTouch.moveTouch, true);
- };
- this.deactivateTouchend = function() {
- this.elm.removeEventListener("touchend", defaultTouch.endTouch, true);
- };
- this.setDeactivate = function() {
- this.activ = true;
- };
-
- this.isActiv = function() {
- return this.activ;
- }
-//
-// this.registerObject = function(obj) {
-// this.obj = obj;
-// alert(this.obj);
-// };
-
- this.startTouch = function(event) {
- event.preventDefault();
- var elm = findElement(event, "");
- if (isSingleTouch(event)) {
- defaultTouch.startPos = new Mapbender.Point(
- event.touches[0].pageX - defaultTouch.$elm.offset().left,
- event.touches[0].pageY - defaultTouch.$elm.offset().top);
- defaultTouch.stopPos = new Point(defaultTouch.startPos.x, defaultTouch.startPos.y);
- var timestamp = new Date().getTime();
- if (timestamp - defaultTouch.timestamp < 300) {
- defaultTouch.dblclick = true;
- }
- defaultTouch.timestamp = timestamp;
- } else if (isMultiTouch(event)) {
- defaultTouch.dblclick = false;
- defaultTouch.move = false;
- defaultTouch.pinch = true;
- defaultTouch.pinchObj = new Pinch(defaultTouch);
- defaultTouch.pinchObj.pinchStart(event);
- }
- return true;
- };
- this.moveTouch = function(event) {
- event.preventDefault();
- var elm = findElement(event, "");
- if (isSingleTouch(event)) {
- defaultTouch.moveMapMove(event);
- defaultTouch.move = true;
- } else if(isMultiTouch(event)) {
- defaultTouch.pinchObj.pinchRun(event);
- }
- return true;
- };
- this.endTouch = function(event) {
- event.preventDefault();
- var elm = findElement(event, "");
- if (defaultTouch.dblclick) {
- defaultTouch.zoomSingle(event);
- defaultTouch.dblclick = false;
- } else {
- if (defaultTouch.move) {
- defaultTouch.moveMapStop(event);
- defaultTouch.move = false;
- } else if (defaultTouch.pinch){
- defaultTouch.pinchObj.pinchStop(event);
- defaultTouch.pinch = false;
- }
- }
- return true;
- };
-
- this.moveMapMove = function(event){
- this.stopPos = new Mapbender.Point(
- event.touches[0].pageX - this.$elm.offset().left,
- event.touches[0].pageY - this.$elm.offset().top);
- var dif = this.stopPos.minus(this.startPos);
- this.map.moveMap(dif.x, dif.y);
- };
-
- this.moveMapStop = function(event){
- var dif = this.stopPos.minus(this.startPos);
- var mapCenter = new Mapbender.Point(
- parseInt(parseInt(this.map.getWidth()) / 2),
- parseInt(parseInt(this.map.getHeight()) / 2)
- );
- var center = mapCenter.minus(dif);
- var realCenter = this.map.convertPixelToReal(center);
- this.map.moveMap(dif.x, dif.y);
- this.map.zoom(false, 1.0, realCenter);
- this.startPos = null;
- this.stopPos = null;
- };
-
- this.zoomSingle = function(event){
- var pos = this.map.convertPixelToReal(this.stopPos);
- var extentAfterZoom = this.map.calculateExtentAfterZoom(
- true,
- 2.0,
- pos.x,
- pos.y
- );
- var newPos = this.map.convertRealToPixel(
- pos,
- extentAfterZoom
- );
- var diff = newPos.minus(this.stopPos);
-
- var newSouthEast = this.map.convertPixelToReal(
- (new Point(0, this.map.getHeight())).plus(diff),
- extentAfterZoom
- );
- var newNorthWest = this.map.convertPixelToReal(
- (new Point(this.map.getWidth(), 0)).plus(diff),
- extentAfterZoom
- );
- var newExtent = new Mapbender.Extent(newSouthEast, newNorthWest);
- this.map.setExtent(newExtent);
- this.map.setMapRequest();
- };
-
- function findElement(event, tagName) {
- var element = getElement(event);
- while (element.parentNode && (!element.tagName ||
- (element.tagName.toUpperCase() != tagName.toUpperCase()))){
- element = element.parentNode;
- return element;
- }
- }
-
- function getElement(event) {
- return event.target || event.srcElement;
- }
-
- function isSingleTouch(event) {
- return event.touches && event.touches.length == 1;
- }
-
- function isMultiTouch(event) {
- return event.touches && event.touches.length > 1;
- }
-
- function Pinch(mmtouch){
- this.mmtouch = mmtouch;
- this.scale = 1;
-
- this.pinchStart = function(event) {
- this.pinchCenter = new Mapbender.Point(
- parseInt((event.touches[0].pageX - this.mmtouch.$elm.offset().left +
- event.touches[1].pageX - this.mmtouch.$elm.offset().left) / 2),
- parseInt((event.touches[0].pageY - this.mmtouch.$elm.offset().top +
- event.touches[1].pageY - this.mmtouch.$elm.offset().top) / 2));
-
- this.pos0 = new Mapbender.Point(
- event.touches[0].pageX - this.mmtouch.$elm.offset().left,
- event.touches[0].pageY - this.mmtouch.$elm.offset().top);
- this.pos1 = new Mapbender.Point(
- event.touches[1].pageX - this.mmtouch.$elm.offset().left,
- event.touches[1].pageY - this.mmtouch.$elm.offset().top);
- this.startDist = Math.sqrt(
- Math.pow(this.pos0.x - this.pos1.x, 2) +
- Math.pow(this.pos0.y - this.pos1.y, 2));
- }
-
- this.pinchRun = function(event) {
-
- this.lastPinchCenter = new Mapbender.Point(
- parseInt((event.touches[0].pageX - this.mmtouch.$elm.offset().left +
- event.touches[1].pageX - this.mmtouch.$elm.offset().left) / 2),
- parseInt((event.touches[0].pageY - this.mmtouch.$elm.offset().top +
- event.touches[1].pageY - this.mmtouch.$elm.offset().top) / 2));
- // var dif = this.lastCenter.minus(this.center);
- var pos0 = new Mapbender.Point(
- event.touches[0].pageX - this.mmtouch.$elm.offset().left,
- event.touches[0].pageY - this.mmtouch.$elm.offset().top);
- var pos1 = new Mapbender.Point(
- event.touches[1].pageX - this.mmtouch.$elm.offset().left,
- event.touches[1].pageY - this.mmtouch.$elm.offset().top);
- var dist = Math.sqrt(
- Math.pow(pos0.x - pos1.x, 2) +
- Math.pow(pos0.y - pos1.y, 2));
- this.scale = dist / this.startDist;
-
- var index = this.mmtouch.map.history.getCurrentIndex();
- var width = parseInt(parseInt(this.mmtouch.$elm.css("width")) * this.scale);
- var height = parseInt(parseInt(this.mmtouch.$elm.css("height")) * this.scale);
- var leftAt = parseInt(this.lastPinchCenter.x * this.scale);
- var topAt = parseInt(this.lastPinchCenter.y * this.scale);
- var left = this.lastPinchCenter.x - leftAt;
- var top = this.lastPinchCenter.y - topAt;
- $("#" + this.mmtouch.map.elementName + "_request_" + (index) + " div img").css({
- position: "absolute",
- width: width + "px",
- height: height + "px",
- left: left + "px",
- top: top + "px"
- });
- }
- this.pinchStop = function(event) {
- var pos = this.mmtouch.map.convertPixelToReal(this.lastPinchCenter);
-// var dist = this.startDist * this.scale;
-// var isZoomIn = false;
-// if (this.startDist - dist < 0){
-// isZoomIn = true;
-// }
- var extentAfterZoom = this.mmtouch.map.calculateExtentAfterZoom(
- true,
- this.scale,
- pos.x,
- pos.y
- );
- var newPos = this.mmtouch.map.convertRealToPixel(
- pos,
- extentAfterZoom
- );
-
- var diff = newPos.minus(this.lastPinchCenter);
-
- var newSouthEast = this.mmtouch.map.convertPixelToReal(
- (new Point(0, this.mmtouch.map.getHeight())).plus(diff),
- extentAfterZoom
- );
- var newNorthWest = this.mmtouch.map.convertPixelToReal(
- (new Point(this.mmtouch.map.getWidth(), 0)).plus(diff),
- extentAfterZoom
- );
- var newExtent = new Mapbender.Extent(newSouthEast, newNorthWest);
- this.mmtouch.map.setExtent(newExtent);
- this.mmtouch.map.setMapRequest();
- }
- }
-}
\ No newline at end of file
Modified: branches/mobile/http/javascripts/mod_box1.js
===================================================================
--- branches/mobile/http/javascripts/mod_box1.js 2011-08-02 12:00:04 UTC (rev 8043)
+++ branches/mobile/http/javascripts/mod_box1.js 2011-08-02 12:12:12 UTC (rev 8044)
@@ -229,3 +229,216 @@
bottomNode = document.getElementById(map.elementName + bottomSuffix);
}
};
+
+Mapbender.BoxMobile = function (options) {
+ var map = (typeof options.target !== "undefined") ?
+ getMapObjByName(options.target) : null;
+
+ var color = (typeof options.color !== "undefined") ?
+ options.color : "#ff0000";
+
+ var isActive = false;
+ var top = 0;
+ var topSuffix = "_l_top";
+ var topNode;
+ var left = 0;
+ var leftSuffix = "_l_left";
+ var leftNode;
+ var bottom = 0;
+ var bottomSuffix = "_l_bottom";
+ var bottomNode;
+ var right = 0;
+ var rightSuffix = "_l_right";
+ var rightNode;
+
+ var startPos = null;
+ var stopPos = null;
+
+ var exists = false;
+ var that = this;
+
+ this.start = function (startPosition, stopPosition) {
+ startPos = startPosition;
+ stopPos = stopPosition;
+ isActive = true;
+ top = startPos.y;
+ left = startPos.y;
+ bottom = startPos.y;
+ right = startPos.x;
+ return true;
+ };
+
+ this.run = function (startPosition, stopPosition) {
+ if (startPosition !== null && stopPosition != null) {
+ startPos = startPosition
+ stopPos = stopPosition;
+ var width = map.width;
+ var height = map.height;
+
+ if (startPos.x > stopPos.x) {
+ right = startPos.x;
+ left = stopPos.x;
+ }
+ else {
+ left = startPos.x;
+ right = stopPos.x;
+ }
+ if (startPos.y > stopPos.y) {
+ bottom = startPos.y;
+ top = stopPos.y;
+ }
+ else {
+ top = startPos.y;
+ bottom = stopPos.y;
+ }
+
+ if (!startPos.equals(stopPos)) {
+ this.draw();
+ }
+ }
+ return true;
+ };
+
+ this.stop = function (callback) {
+ hideElement(topNode);
+ hideElement(leftNode);
+ hideElement(rightNode);
+ hideElement(bottomNode);
+
+ if (isActive) {
+ isActive = false;
+ if (typeof callback === "function") {
+ return callback(getExtent());
+ }
+ return getExtent();
+ }
+ isActive = false;
+ };
+
+ var arrangeBox = function (node, left, top, right, bottom) {
+ var el = node.style;
+ el.height = Math.abs(bottom - top) + "px";
+ el.width = Math.abs(right - left) + "px";
+ el.top = top + "px";
+ el.left = left + "px";
+ };
+
+ var displayElement = function (node) {
+ node.style.visibility = "visible";
+ };
+
+ var hideElement = function (node) {
+ node.style.visibility = "hidden";
+ };
+
+ var domElementsExist = function () {
+ if (!map) {
+ return;
+ }
+ return map.getDomElement(
+ ).ownerDocument.getElementById(
+ map.elementName + topSuffix
+ ) !== null;
+ };
+
+ var createDomElements = function () {
+ if (!map) {
+ return;
+ }
+ var map_el = map.getDomElement();
+ topNode = map_el.ownerDocument.createElement("div");
+ topNode.style.position = "absolute";
+ topNode.style.top = "0px";
+ topNode.style.left = "0px";
+ topNode.style.width = "0px";
+ topNode.style.height = "0px";
+ topNode.style.overflow = "hidden";
+ // topNode.style.zIndex = parseInt(map_el.style.zIndex, 10) + 1;
+ topNode.style.zIndex = 100;
+ topNode.style.visibility = "visible";
+ topNode.style.cursor = "crosshair";
+ topNode.style.backgroundColor = color;
+
+ leftNode = topNode.cloneNode(false);
+ rightNode = topNode.cloneNode(false);
+ bottomNode = topNode.cloneNode(false);
+
+ topNode.id = map.elementName + topSuffix;
+ leftNode.id = map.elementName + leftSuffix;
+ rightNode.id = map.elementName + rightSuffix;
+ bottomNode.id = map.elementName + bottomSuffix;
+
+ map_el.appendChild(topNode);
+ map_el.appendChild(leftNode);
+ map_el.appendChild(rightNode);
+ map_el.appendChild(bottomNode);
+
+ exists = true;
+ };
+
+ this.draw = function (extent) {
+ if (!map) {
+ return;
+ }
+ if (typeof extent === "object"
+ && extent.constructor === Mapbender.Extent) {
+
+ left = extent.min.x;
+ right = extent.max.x;
+ bottom = extent.min.y;
+ top = extent.max.y;
+ }
+
+ arrangeBox(topNode, left, top, right, top + 2);
+ arrangeBox(leftNode, left, top, left + 2, bottom);
+ arrangeBox(rightNode, right - 2, top, right, bottom);
+ arrangeBox(bottomNode, left, bottom - 2, right, bottom);
+ displayElement(topNode);
+ displayElement(leftNode);
+ displayElement(rightNode);
+ displayElement(bottomNode);
+ };
+
+ var getExtent = function () {
+ if (!map) {
+ return null;
+ }
+ var x1 = startPos.x;
+ var x2 = stopPos.x;
+ var y1 = startPos.y;
+ var y2 = stopPos.y;
+
+ var minx = x2;
+ var maxx = x1;
+ if(x1 < x2){
+ minx = x1;
+ maxx = x2;
+ }
+
+ var miny = y1;
+ var maxy = y2;
+ if(y1 < y2){
+ miny = y2;
+ maxy = y1;
+ }
+
+ // area or clickpoint ?
+ var posMin = map.convertPixelToReal(new Point(minx,miny));
+ if((maxx - minx) > 3 && (miny - maxy) > 3){
+ var posMax = map.convertPixelToReal(new Point(maxx,maxy));
+ return new Mapbender.Extent(posMin, posMax);
+ }
+ return posMin;
+ };
+
+ if (!domElementsExist()) {
+ createDomElements();
+ }
+ else {
+ topNode = document.getElementById(map.elementName + topSuffix);
+ leftNode = document.getElementById(map.elementName + leftSuffix);
+ rightNode = document.getElementById(map.elementName + rightSuffix);
+ bottomNode = document.getElementById(map.elementName + bottomSuffix);
+ }
+};
+
Modified: branches/mobile/http/javascripts/mod_dragMapSize.php
===================================================================
--- branches/mobile/http/javascripts/mod_dragMapSize.php 2011-08-02 12:00:04 UTC (rev 8043)
+++ branches/mobile/http/javascripts/mod_dragMapSize.php 2011-08-02 12:12:12 UTC (rev 8044)
@@ -1,7 +1,7 @@
<?php
# $Id$
# http://www.mapbender.org/index.php/mod_dragMapSize.php
-# Copyright (C) 2002 CCGIS
+# Copyright (C) 2002 CCGIS
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -22,6 +22,9 @@
?>
var mod_dragMapSize_offset = 15;
var mod_dragMapSize_active = false;
+var isTouchable = false;
+var isMainTouchActiv = false;
+try {document.createEvent("TouchEvent"); isTouchable = true; } catch(e){}
eventInit.register(function () {
mod_dragMapSize_init();
@@ -31,45 +34,185 @@
mod_dragMapSize_arrange()
});
+function mod_dragMapSize_init(){
+ var el = document.getElementById("dragMapSize");
+ if (isTouchable) {
+ $('.ui-icon').css({width:'30px',height:'30px'});
+ el.addEventListener("mousedown", mod_dragMapSize_touchOn, true);
+ el.addEventListener("mouseup", mod_dragMpaSize_touchOff, true);
+ el.addEventListener("touchstart", mod_dragMapSize_touchOn, true);
+ } else {
+// $('.ui-icon').css({width:'30px',height:'30px'});
+ el.onmousedown = mod_dragMapSize_down;
+ }
+ $(el).hover(function () {
+ $(this).addClass("ui-state-hover");
+ },
+ function () {
+ $(this).removeClass("ui-state-hover");
+ }
+ );
+ mod_dragMapSize_arrange();
+}
+
function mod_dragMapSize_arrange(){
- var left = parseInt(document.getElementById(mod_dragMapSize_target).style.left, 10) +
- parseInt(document.getElementById(mod_dragMapSize_target).style.width, 10) +
- mod_dragMapSize_offset -
- (parseInt(document.getElementById('dragMapSize').style.width, 10)/2);
- var top = parseInt(document.getElementById(mod_dragMapSize_target).style.top, 10) +
- parseInt(document.getElementById(mod_dragMapSize_target).style.height, 10) +
- mod_dragMapSize_offset -
- (parseInt(document.getElementById('dragMapSize').style.height, 10)/2);
+ var left = parseInt(document.getElementById(mod_dragMapSize_target).style.left, 10) +
+ parseInt(document.getElementById(mod_dragMapSize_target).style.width, 10) +
+ mod_dragMapSize_offset -
+ (parseInt(document.getElementById('dragMapSize').style.width, 10)/2);
+ var top = parseInt(document.getElementById(mod_dragMapSize_target).style.top, 10) +
+ parseInt(document.getElementById(mod_dragMapSize_target).style.height, 10) +
+ mod_dragMapSize_offset -
+ (parseInt(document.getElementById('dragMapSize').style.height, 10)/2);
mb_arrangeElement('','dragMapSize' , left, top);
}
+function mod_dragMapSize_touchOn(e){
-function mod_dragMapSize_init(){
- var el = document.getElementById("dragMapSize");
- el.onmousedown = mod_dragMapSize_down;
- $(el).hover(function () {
- $(this).addClass("ui-state-hover");
- },
- function () {
- $(this).removeClass("ui-state-hover");
- }
- );
- mod_dragMapSize_arrange();
+ body.addEventListener("touchstart", mod_dragMapSize_touch_down, true);
+ body.addEventListener("touchmove", mod_dragMapSize_touch_drag, true);
+ body.addEventListener("touchend", mod_dragMapSize_touch_up, true);
+ mod_dragMapSize_touch_down(e);
}
+function mod_dragMpaSize_touchOff(e){
+ body.removeEventListener("touchstart", mod_dragMapSize_touch_down, true);
+ body.removeEventListener("touchmove", mod_dragMapSize_touch_drag, true);
+ body.removeEventListener("touchend", mod_dragMapSize_touch_up, true);
+}
+function mod_dragMapSize_touch_down(e){
+ e.preventDefault();
+ var elm = findElement(e, "");
+ if(mod_dragMapSize_active == false && isSingleTouch(e)){
+
+ mb_start_x = e.touches[0].pageX;
+ mb_start_y = e.touches[0].pageY;
+ mb_end_x = mb_start_x;
+ mb_end_y = mb_start_y;
+
+ mod_dragMapSize_active = true;
+
+ //create a div that catches all mouse interactions
+ var dragElement = document.getElementById("dragMapSize");
+ $('.ui-state-active').css({width:'30px',height:'30px'});
+ $(dragElement).addClass("ui-state-active");
+ var mouseCatcher = dragElement.parentNode.appendChild(document.createElement('div'));
+ mouseCatcher.setAttribute("id", "dragMapSize_helper");
+ mouseCatcher.style.position = "absolute";
+ mouseCatcher.style.cursor = "move";
+ mouseCatcher.style.width = "200px";
+ mouseCatcher.style.height = "200px";
+ mouseCatcher.style.zIndex = 160;
+ if($.browser.msie)
+ mouseCatcher.style.background = "url(../img/transparent.gif)";
+ mouseCatcher.style.left=(mb_start_x-parseInt(mouseCatcher.style.width)) + "px";
+ mouseCatcher.style.top=(mb_start_x-parseInt(mouseCatcher.style.height)) + "px";
+ }
+ return true;
+}
+
+function mod_dragMapSize_touch_drag(e){
+ e.preventDefault();
+ var elm = findElement(e, "");
+ if(mod_dragMapSize_active && isSingleTouch(e)){
+// var x, y;
+ mb_end_x = e.touches[0].pageX;
+ mb_end_y = e.touches[0].pageY;
+ var dif_x = mb_end_x - (parseInt(document.getElementById('dragMapSize').style.width)/2);
+ var dif_y = mb_end_y - (parseInt(document.getElementById('dragMapSize').style.height)/2);
+ mb_arrangeElement('', "dragMapSize", dif_x, dif_y);
+ var mouseCatcher = document.getElementById("dragMapSize_helper");
+ mb_arrangeElement('', "dragMapSize_helper", mb_end_x-parseInt(mouseCatcher.style.width), mb_end_y-parseInt(mouseCatcher.style.height));
+ }
+}
+
+function mod_dragMapSize_touch_up(e){
+ e.preventDefault();
+ var elm = findElement(e, "");
+ body.removeEventListener("touchstart", mod_dragMapSize_touch_down, true);
+ body.removeEventListener("touchmove", mod_dragMapSize_touch_drag, true);
+ body.removeEventListener("touchend", mod_dragMapSize_touch_up, true);
+// if (isMainTouchActiv) {
+// $.extend(Mapbender.modules.mobile_Map).defaultTouch.activate();
+// }
+
+// if (isSingleTouch(e)) {
+// mb_end_x = e.touches[0].pageX;
+// mb_end_y = e.touches[0].pageY;
+
+
+ var dragElement = document.getElementById("dragMapSize");
+ $(dragElement).removeClass("ui-state-active");
+
+ var mouseCatcher = document.getElementById("dragMapSize_helper");
+ mouseCatcher.parentNode.removeChild(mouseCatcher);
+
+ mod_dragMapSize_active = false;
+
+ targetObject = getMapObjByName(mod_dragMapSize_target);
+ var dif_x = (parseFloat(mb_end_x) - parseFloat(mb_start_x));
+ var dif_y = (parseFloat(mb_end_y) - parseFloat(mb_start_y));
+
+ if(parseFloat(targetObject.width) + parseFloat(dif_x)<0 ||
+ parseFloat(targetObject.height) + parseFloat(dif_y)<0){
+
+ var dif_x = mb_start_x - (parseInt(document.getElementById('dragMapSize').style.width) / 2);
+ var dif_y = mb_start_y - (parseInt(document.getElementById('dragMapSize').style.height) / 2);
+ mb_arrangeElement('', "dragMapSize", dif_x, dif_y);
+ return true;
+ }
+
+ var newX = (parseFloat(targetObject.width) + parseFloat(dif_x));
+ var newY = (parseFloat(targetObject.height) + parseFloat(dif_y));
+ var pos = makeClickPos2RealWorldPos(mod_dragMapSize_target, newX, newY);
+ targetObject.setWidth(targetObject.getWidth() + parseFloat(dif_x));
+ targetObject.setHeight(targetObject.getHeight() + parseFloat(dif_y));
+
+ var mybbox = targetObject.getExtent().split(",");
+ if (typeof mybbox !== "object" || mybbox.length !== 4) {
+ return;
+ }
+ targetObject.setExtent(mybbox[0], pos[1], pos[0], mybbox[3]);
+ targetObject.setMapRequest();
+ eventResizeMap.trigger();
+// }
+ return true;
+}
+
+function findElement(event, tagName) {
+ var element = getElement(event);
+ while (element.parentNode && (!element.tagName ||
+ (element.tagName.toUpperCase() != tagName.toUpperCase()))){
+ element = element.parentNode;
+ return element;
+ }
+}
+
+function getElement(event) {
+ return event.target || event.srcElement;
+}
+
+function isSingleTouch(event) {
+ return event.touches && event.touches.length == 1;
+}
+
+function isMultiTouch(event) {
+ return event.touches && event.touches.length > 1;
+}
+
function mod_dragMapSize_down(e){
if(mod_dragMapSize_active == false){
- document.onmouseup = mod_dragMapSize_up;
- document.onmousemove = mod_dragMapSize_drag;
-
- mb_getMousePos(e);
- mb_start_x = clickX;
- mb_start_y = clickY;
- mb_end_x = clickX;
- mb_end_y = clickY;
+ document.onmouseup = mod_dragMapSize_up;
+ document.onmousemove = mod_dragMapSize_drag;
+ mb_getMousePos(e);
+ mb_start_x = clickX;
+ mb_start_y = clickY;
+ mb_end_x = clickX;
+ mb_end_y = clickY;
mod_dragMapSize_active = true;
//create a div that catches all mouse interactions
var dragElement = document.getElementById("dragMapSize");
+// $('.ui-state-active').css({width:'30px',height:'30px'});
$(dragElement).addClass("ui-state-active");
var mouseCatcher = dragElement.parentNode.appendChild(document.createElement('div'));
mouseCatcher.setAttribute("id", "dragMapSize_helper");
@@ -79,32 +222,31 @@
mouseCatcher.style.height = "500px";
mouseCatcher.style.zIndex = 160;
if($.browser.msie)
- mouseCatcher.style.background = "url(../img/transparent.gif)";
- mouseCatcher.style.left=(clickX-250) + "px";
- mouseCatcher.style.top=(clickY-250) + "px";
-
+ mouseCatcher.style.background = "url(../img/transparent.gif)";
+ mouseCatcher.style.left=(mb_start_x-parseInt(mouseCatcher.style.width)) + "px";
+ mouseCatcher.style.top=(mb_start_x-parseInt(mouseCatcher.style.height)) + "px";
+
return false;
}
}
-function mod_dragMapSize_up(e){
- document.onmouseup = null;
- document.onmousemove = null;
-
+function mod_dragMapSize_up(e){
+ mb_getMousePos(e);
+ mb_end_x = clickX;
+ mb_end_y = clickY;
+ document.onmouseup = null;
+ document.onmousemove = null;
var dragElement = document.getElementById("dragMapSize");
$(dragElement).removeClass("ui-state-active");
var mouseCatcher = document.getElementById("dragMapSize_helper");
mouseCatcher.parentNode.removeChild(mouseCatcher);
-
+
mod_dragMapSize_active = false;
- mb_getMousePos(e);
- mb_end_x = clickX;
- mb_end_y = clickY;
+
targetObject = getMapObjByName(mod_dragMapSize_target);
var dif_x = (parseFloat(mb_end_x) - parseFloat(mb_start_x));
var dif_y = (parseFloat(mb_end_y) - parseFloat(mb_start_y));
-
if(parseFloat(targetObject.width) + parseFloat(dif_x)<0 ||
parseFloat(targetObject.height) + parseFloat(dif_y)<0)
{
@@ -119,10 +261,10 @@
targetObject.setWidth(targetObject.getWidth() + parseFloat(dif_x));
targetObject.setHeight(targetObject.getHeight() + parseFloat(dif_y));
- var mybbox = targetObject.getExtent().split(",");
- if (typeof mybbox !== "object" || mybbox.length !== 4) {
- return;
- }
+ var mybbox = targetObject.getExtent().split(",");
+ if (typeof mybbox !== "object" || mybbox.length !== 4) {
+ return;
+ }
targetObject.setExtent(mybbox[0], pos[1], pos[0], mybbox[3]);
targetObject.setMapRequest();
eventResizeMap.trigger();
@@ -130,12 +272,16 @@
function mod_dragMapSize_drag(e){
if(mod_dragMapSize_active){
- if (!e)
- e = window.event;
- mb_getMousePos(e);
- var dif_x = clickX - (parseInt(document.getElementById('dragMapSize').style.width)/2);
- var dif_y = clickY - (parseInt(document.getElementById('dragMapSize').style.height)/2);
- mb_arrangeElement('', "dragMapSize", dif_x, dif_y);
- mb_arrangeElement('', "dragMapSize_helper", clickX-250, clickY-250);
+ var x, y;
+ if (!e)
+ e = window.event;
+ mb_getMousePos(e);
+ x = clickX;
+ y = clickY;
+ var dif_x = x - (parseInt(document.getElementById('dragMapSize').style.width)/2);
+ var dif_y = y - (parseInt(document.getElementById('dragMapSize').style.height)/2);
+ mb_arrangeElement('', "dragMapSize", dif_x, dif_y);
+ mb_arrangeElement('', "dragMapSize_helper", x-250, y-250);
}
}
+
Modified: branches/mobile/http/javascripts/mod_featureInfoTunnel.php
===================================================================
--- branches/mobile/http/javascripts/mod_featureInfoTunnel.php 2011-08-02 12:00:04 UTC (rev 8043)
+++ branches/mobile/http/javascripts/mod_featureInfoTunnel.php 2011-08-02 12:12:12 UTC (rev 8044)
@@ -1,7 +1,7 @@
<?php
# $Id$
# http://www.mapbender.org/index.php/mod_featureInfoTunnel.php
-# Copyright (C) 2002 CCGIS
+# Copyright (C) 2002 CCGIS
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -31,7 +31,7 @@
if(typeof(featureInfoPopupPosition)==='undefined')
var featureInfoPopupPosition = 'center';
if(typeof(featureInfoNoResultPopup)==='undefined')
- var featureInfoNoResultPopup = 'false';
+ var featureInfoNoResultPopup = 'false';
var mod_featureInfoTunnel_elName = "featureInfoTunnel";
var mod_featureInfoTunnel_frameName = "";
@@ -43,6 +43,10 @@
var mod_featureInfoTunnel_img_over = new Image(); mod_featureInfoTunnel_img_over.src = "<?php echo preg_replace("/_off/","_over",$e_src); ?>";
function init_featureInfoTunnel(ind){
+ mod_featureInfoTunnel_map = getMapObjByName(mod_featureInfoTunnel_target);
+ if ($.extend(mod_featureInfoTunnel_map).defaultTouch) {
+ $.extend(mod_featureInfoTunnel_map).defaultTouch.deactivate();
+ }
mb_button[ind] = document.getElementById(mod_featureInfoTunnel_elName);
mb_button[ind].img_over = mod_featureInfoTunnel_img_over.src;
mb_button[ind].img_on = mod_featureInfoTunnel_img_on.src;
@@ -52,10 +56,9 @@
mb_button[ind].fName = mod_featureInfoTunnel_frameName;
mb_button[ind].go = new Function ("mod_featureInfoTunnel_click()");
mb_button[ind].stop = new Function ("mod_featureInfoTunnel_disable()");
-
- mod_featureInfoTunnel_map = getMapObjByName(mod_featureInfoTunnel_target);
+
}
-function mod_featureInfoTunnel_click(){
+function mod_featureInfoTunnel_click(){
var domNode = mod_featureInfoTunnel_map.getDomElement();
if (domNode) {
$(domNode).bind("click", mod_featureInfoTunnel_event);
@@ -68,8 +71,12 @@
if (domNode) {
$(domNode).unbind("click", mod_featureInfoTunnel_event);
}
-
+
mod_featureInfoTunnel_map.getDomElement().style.cursor = "default";
+
+ if ($.extend(mod_featureInfoTunnel_map).defaultTouch) {
+ $.extend(mod_featureInfoTunnel_map).defaultTouch.activate();
+ }
}
function removeProgressWheel () {
@@ -79,7 +86,7 @@
function mod_featureInfoTunnel_event(e){
eventBeforeFeatureInfo.trigger({"fName":mod_featureInfoTunnel_target});
-
+
//create progress wheel element
var map_el = mod_featureInfoTunnel_map.getDomElement();
if (!map_el.ownerDocument.getElementById(mod_featureInfoTunnel_map.elementName + "_progressWheel")) {
@@ -91,7 +98,7 @@
var point = mod_featureInfoTunnel_map.getMousePosition(e);
var path = '../extensions/ext_featureInfoTunnel.php';
-
+
//TODO that code should go to featureInfo Redirect module
var ind = getMapObjIndexByName(mod_featureInfoTunnel_target);
if(document.getElementById("FeatureInfoRedirect")){
@@ -107,7 +114,7 @@
if(urls){
for(var i=0;i<urls.length;i++){
(function () {
- var currentMapObjWidth = point.x;
+ var currentMapObjWidth = point.x;
var currentMapObjHeight = point.y;
$("#" + mod_featureInfoTunnel_map.elementName + "_progressWheel").html("<img src='../img/indicator_wheel.gif'/>");
$("#" + mod_featureInfoTunnel_map.elementName + "_progressWheel").css({
@@ -129,7 +136,7 @@
var dialogPosition = featureInfoPopupPosition;
}
$(".fiResultFrame").remove();
-
+
mb_ajax_post(path, {'url':currentRequest},function(js_code,status){
if(js_code){
if(featureInfoLayerPopup == 'true') {
@@ -152,14 +159,14 @@
$(this).remove();
}
});
-
+
$(".noResultFound").dialog("close");
}
else{
window.open(path+"?url=" + encodeURIComponent(currentRequest), "" , "width="+featureInfoPopupWidth+",height="+featureInfoPopupHeight+",scrollbars=yes,resizable=yes");
}
}
-
+
if(featureInfoNoResultPopup == 'true' && featureInfoLayerPopup == 'true') {
if($(".fiResultFrame").size() === 0) {
$(".noResultFound").dialog("close");
@@ -173,7 +180,7 @@
position:[600,200]
});
}
- }
+ }
removeProgressWheel();
});
}());
@@ -181,5 +188,5 @@
}
else
alert(unescape("Please select a layer! \n Bitte waehlen Sie eine Ebene zur Abfrage aus!"));
- }
+ }
}
Modified: branches/mobile/http/javascripts/mod_pan.js
===================================================================
--- branches/mobile/http/javascripts/mod_pan.js 2011-08-02 12:00:04 UTC (rev 8043)
+++ branches/mobile/http/javascripts/mod_pan.js 2011-08-02 12:12:12 UTC (rev 8044)
@@ -3,36 +3,42 @@
*
* Description:
* Zoom by rectangle
- *
+ *
* Files:
* - http/javascripts/mod_selArea.js
*
* SQL:
- * > <SQL for element>
- * >
- * > <SQL for element var>
+ * > <SQL for element>
+ * >
+ * > <SQL for element var>
*
* Help:
* http://www.mapbender.org/SelArea1
*
* Maintainer:
* http://www.mapbender.org/User:Christoph_Baudson
- *
+ *
* License:
* Copyright (c) 2009, Open Source Geospatial Foundation
- * This program is dual licensed under the GNU General Public License
- * and Simplified BSD license.
+ * This program is dual licensed under the GNU General Public License
+ * and Simplified BSD license.
* http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
*/
var that = this;
Mapbender.events.init.register(function () {
-
+
var mb_panActive = false;
var startPos, stopPos;
var map = Mapbender.modules[options.target];
-
+ var isTouchable = false;
+ var touch;
+ try {
+ document.createEvent("TouchEvent");
+ isTouchable = true;
+ } catch(e){}
+
var button = new Mapbender.Button({
domElement: that,
over: options.src.replace(/_off/, "_over"),
@@ -41,58 +47,353 @@
name: options.id,
go: function () {
if (!map) {
- new Mb_exception(options.id + ": " +
+ new Mb_exception(options.id + ": " +
options.target + " is not a map!");
return;
}
- $(map.getDomElement())
- .css("cursor", "move")
- .mousedown(function (e) {
- mb_panActive = true;
- startPos = map.getMousePosition(e);
- stopPos = new Point(startPos);
- return false;
- }).mousemove(function (e) {
- if (!mb_panActive) {
- return false;
- }
- stopPos = map.getMousePosition(e);
- var dif = stopPos.minus(startPos);
- map.moveMap(dif.x, dif.y);
- if (!$.browser.msie){
- return true;
- }
- return false;
- }).mouseup(function (e) {
- if (!mb_panActive) {
- return false;
- }
- if (!map) {
- return false;
- }
- mb_panActive = false;
- var dif = stopPos.minus(startPos);
- var widthHeight = new Mapbender.Point(
- map.getWidth(),
- map.getHeight()
- );
- var center = widthHeight.times(0.5).minus(dif);
- var realCenter = map.convertPixelToReal(center);
- map.moveMap();
- map.zoom(false, 1.0, realCenter);
- return false;
- });
+ if(isTouchable) {
+ $(map.getDomElement()).css("cursor", "crosshair");
+
+ if ($.extend(map).defaultTouch) {
+ $.extend(map).defaultTouch.deactivate();
+ }
+ touch = new MapTouch(map, $(map.getDomElement()), map.getDomElement());
+ touch.activate();
+ } else {
+ $(map.getDomElement())
+ .css("cursor", "move")
+ .mousedown(function (e) {
+ mb_panActive = true;
+ startPos = map.getMousePosition(e);
+ stopPos = new Point(startPos);
+ return false;
+ }).mousemove(function (e) {
+ if (!mb_panActive) {
+ return false;
+ }
+ stopPos = map.getMousePosition(e);
+ var dif = stopPos.minus(startPos);
+ map.moveMap(dif.x, dif.y);
+ if (!$.browser.msie){
+ return true;
+ }
+ return false;
+ }).mouseup(function (e) {
+ if (!mb_panActive) {
+ return false;
+ }
+ if (!map) {
+ return false;
+ }
+ mb_panActive = false;
+ var dif = stopPos.minus(startPos);
+ var widthHeight = new Mapbender.Point(
+ map.getWidth(),
+ map.getHeight()
+ );
+ var center = widthHeight.times(0.5).minus(dif);
+ var realCenter = map.convertPixelToReal(center);
+ map.moveMap();
+ map.zoom(false, 1.0, realCenter);
+ return false;
+ });
+ }
},
stop: function () {
if (!map) {
return false;
}
- $(map.getDomElement())
- .css("cursor", "default")
- .unbind("mousedown")
- .unbind("mouseup")
- .unbind("mousemove");
- mb_panActive = false;
+ if(isTouchable) {
+ $(map.getDomElement()).css("cursor", "default");
+ touch.deactivate();
+ touch = null;
+ mb_panActive = false;
+ if ($.extend(map).defaultTouch) {
+ $.extend(map).defaultTouch.activate();
+ }
+ } else {
+ $(map.getDomElement())
+ .css("cursor", "default")
+ .unbind("mousedown")
+ .unbind("mouseup")
+ .unbind("mousemove");
+ mb_panActive = false;
+ }
}
});
+ var defaultTouch;
+ function MapTouch(map, $map, mapDom){
+ this.map = map;
+ this.$elm = $map;
+ this.elm = mapDom;
+
+ this.started = false;
+ this.startPos = 0, this.stopPos = 0;
+ this.timestamp = 0;
+ this.dblclick = false;
+ this.move = false;
+ this.pinch = false;
+ this.pinchObj = null;
+ this.activ = false;
+ defaultTouch = this;
+
+ this.activate = function() {
+ this.elm.addEventListener("touchstart", defaultTouch.startTouch, true);
+ this.elm.addEventListener("touchmove", defaultTouch.moveTouch, true);
+ this.elm.addEventListener("touchend", defaultTouch.endTouch, true);
+ this.activ = true;
+ };
+ this.activateTouchstart = function() {
+ this.elm.addEventListener("touchstart", defaultTouch.startTouch, true);
+ };
+ this.activateTouchmove = function() {
+ this.elm.addEventListener("touchmove", defaultTouch.moveTouch, true);
+ };
+ this.activateTouchend = function() {
+ this.elm.addEventListener("touchend", defaultTouch.endTouch, true);
+ };
+ this.setActivate = function() {
+ this.activ = true;
+ };
+
+
+ this.deactivate = function() {
+ this.elm.removeEventListener("touchstart", defaultTouch.startTouch, true);
+ this.elm.removeEventListener("touchmove", defaultTouch.moveTouch, true);
+ this.elm.removeEventListener("touchend", defaultTouch.endTouch, true);
+ this.activ = false;
+ };
+ this.deactivateTouchstart = function() {
+ this.elm.removeEventListener("touchstart", defaultTouch.startTouch, true);
+ };
+ this.deactivateTouchmove = function() {
+ this.elm.removeEventListener("touchmove", defaultTouch.moveTouch, true);
+ };
+ this.deactivateTouchend = function() {
+ this.elm.removeEventListener("touchend", defaultTouch.endTouch, true);
+ };
+ this.setDeactivate = function() {
+ this.activ = true;
+ };
+
+ this.isActiv = function() {
+ return this.activ;
+ }
+ //
+ // this.registerObject = function(obj) {
+ // this.obj = obj;
+ // alert(this.obj);
+ // };
+
+ this.startTouch = function(event) {
+ event.preventDefault();
+ var elm = findElement(event, "");
+ if (isSingleTouch(event)) {
+ defaultTouch.startPos = new Mapbender.Point(
+ event.touches[0].pageX - defaultTouch.$elm.offset().left,
+ event.touches[0].pageY - defaultTouch.$elm.offset().top);
+ defaultTouch.stopPos = new Point(defaultTouch.startPos.x, defaultTouch.startPos.y);
+ var timestamp = new Date().getTime();
+ if (timestamp - defaultTouch.timestamp < 300) {
+ defaultTouch.dblclick = true;
+ }
+ defaultTouch.timestamp = timestamp;
+ } else if (isMultiTouch(event)) {
+ defaultTouch.dblclick = false;
+ defaultTouch.move = false;
+ defaultTouch.pinch = true;
+ defaultTouch.pinchObj = new Pinch(defaultTouch);
+ defaultTouch.pinchObj.pinchStart(event);
+ }
+ return true;
+ };
+ this.moveTouch = function(event) {
+ event.preventDefault();
+ var elm = findElement(event, "");
+ if (isSingleTouch(event)) {
+ defaultTouch.moveMapMove(event);
+ defaultTouch.move = true;
+ } else if(isMultiTouch(event)) {
+ defaultTouch.pinchObj.pinchRun(event);
+ }
+ return true;
+ };
+ this.endTouch = function(event) {
+ event.preventDefault();
+ var elm = findElement(event, "");
+ if (defaultTouch.dblclick) {
+ defaultTouch.zoomSingle(event);
+ defaultTouch.dblclick = false;
+ } else {
+ if (defaultTouch.move) {
+ defaultTouch.moveMapStop(event);
+ defaultTouch.move = false;
+ } else if (defaultTouch.pinch){
+ defaultTouch.pinchObj.pinchStop(event);
+ defaultTouch.pinch = false;
+ }
+ }
+ return true;
+ };
+
+ this.moveMapMove = function(event){
+ this.stopPos = new Mapbender.Point(
+ event.touches[0].pageX - this.$elm.offset().left,
+ event.touches[0].pageY - this.$elm.offset().top);
+ var dif = this.stopPos.minus(this.startPos);
+ this.map.moveMap(dif.x, dif.y);
+ };
+
+ this.moveMapStop = function(event){
+ var dif = this.stopPos.minus(this.startPos);
+ var mapCenter = new Mapbender.Point(
+ parseInt(parseInt(this.map.getWidth()) / 2),
+ parseInt(parseInt(this.map.getHeight()) / 2)
+ );
+ var center = mapCenter.minus(dif);
+ var realCenter = this.map.convertPixelToReal(center);
+ this.map.moveMap(dif.x, dif.y);
+ this.map.zoom(false, 1.0, realCenter);
+ this.startPos = null;
+ this.stopPos = null;
+ };
+
+ this.zoomSingle = function(event){
+ var pos = this.map.convertPixelToReal(this.stopPos);
+ var extentAfterZoom = this.map.calculateExtentAfterZoom(
+ true,
+ 2.0,
+ pos.x,
+ pos.y
+ );
+ var newPos = this.map.convertRealToPixel(
+ pos,
+ extentAfterZoom
+ );
+ var diff = newPos.minus(this.stopPos);
+
+ var newSouthEast = this.map.convertPixelToReal(
+ (new Point(0, this.map.getHeight())).plus(diff),
+ extentAfterZoom
+ );
+ var newNorthWest = this.map.convertPixelToReal(
+ (new Point(this.map.getWidth(), 0)).plus(diff),
+ extentAfterZoom
+ );
+ var newExtent = new Mapbender.Extent(newSouthEast, newNorthWest);
+ this.map.setExtent(newExtent);
+ this.map.setMapRequest();
+ };
+
+ function findElement(event, tagName) {
+ var element = getElement(event);
+ while (element.parentNode && (!element.tagName ||
+ (element.tagName.toUpperCase() != tagName.toUpperCase()))){
+ element = element.parentNode;
+ return element;
+ }
+ }
+
+ function getElement(event) {
+ return event.target || event.srcElement;
+ }
+
+ function isSingleTouch(event) {
+ return event.touches && event.touches.length == 1;
+ }
+
+ function isMultiTouch(event) {
+ return event.touches && event.touches.length > 1;
+ }
+
+ function Pinch(mmtouch){
+ this.mmtouch = mmtouch;
+ this.scale = 1;
+
+ this.pinchStart = function(event) {
+ this.pinchCenter = new Mapbender.Point(
+ parseInt((event.touches[0].pageX - this.mmtouch.$elm.offset().left +
+ event.touches[1].pageX - this.mmtouch.$elm.offset().left) / 2),
+ parseInt((event.touches[0].pageY - this.mmtouch.$elm.offset().top +
+ event.touches[1].pageY - this.mmtouch.$elm.offset().top) / 2));
+
+ this.pos0 = new Mapbender.Point(
+ event.touches[0].pageX - this.mmtouch.$elm.offset().left,
+ event.touches[0].pageY - this.mmtouch.$elm.offset().top);
+ this.pos1 = new Mapbender.Point(
+ event.touches[1].pageX - this.mmtouch.$elm.offset().left,
+ event.touches[1].pageY - this.mmtouch.$elm.offset().top);
+ this.startDist = Math.sqrt(
+ Math.pow(this.pos0.x - this.pos1.x, 2) +
+ Math.pow(this.pos0.y - this.pos1.y, 2));
+ }
+
+ this.pinchRun = function(event) {
+
+ this.lastPinchCenter = new Mapbender.Point(
+ parseInt((event.touches[0].pageX - this.mmtouch.$elm.offset().left +
+ event.touches[1].pageX - this.mmtouch.$elm.offset().left) / 2),
+ parseInt((event.touches[0].pageY - this.mmtouch.$elm.offset().top +
+ event.touches[1].pageY - this.mmtouch.$elm.offset().top) / 2));
+ // var dif = this.lastCenter.minus(this.center);
+ var pos0 = new Mapbender.Point(
+ event.touches[0].pageX - this.mmtouch.$elm.offset().left,
+ event.touches[0].pageY - this.mmtouch.$elm.offset().top);
+ var pos1 = new Mapbender.Point(
+ event.touches[1].pageX - this.mmtouch.$elm.offset().left,
+ event.touches[1].pageY - this.mmtouch.$elm.offset().top);
+ var dist = Math.sqrt(
+ Math.pow(pos0.x - pos1.x, 2) +
+ Math.pow(pos0.y - pos1.y, 2));
+ this.scale = dist / this.startDist;
+
+ var index = this.mmtouch.map.history.getCurrentIndex();
+ var width = parseInt(parseInt(this.mmtouch.$elm.css("width")) * this.scale);
+ var height = parseInt(parseInt(this.mmtouch.$elm.css("height")) * this.scale);
+ var leftAt = parseInt(this.lastPinchCenter.x * this.scale);
+ var topAt = parseInt(this.lastPinchCenter.y * this.scale);
+ var left = this.lastPinchCenter.x - leftAt;
+ var top = this.lastPinchCenter.y - topAt;
+ $("#" + this.mmtouch.map.elementName + "_request_" + (index) + " div img").css({
+ position: "absolute",
+ width: width + "px",
+ height: height + "px",
+ left: left + "px",
+ top: top + "px"
+ });
+ }
+ this.pinchStop = function(event) {
+ var pos = this.mmtouch.map.convertPixelToReal(this.lastPinchCenter);
+ // var dist = this.startDist * this.scale;
+ // var isZoomIn = false;
+ // if (this.startDist - dist < 0){
+ // isZoomIn = true;
+ // }
+ var extentAfterZoom = this.mmtouch.map.calculateExtentAfterZoom(
+ true,
+ this.scale,
+ pos.x,
+ pos.y
+ );
+ var newPos = this.mmtouch.map.convertRealToPixel(
+ pos,
+ extentAfterZoom
+ );
+
+ var diff = newPos.minus(this.lastPinchCenter);
+
+ var newSouthEast = this.mmtouch.map.convertPixelToReal(
+ (new Point(0, this.mmtouch.map.getHeight())).plus(diff),
+ extentAfterZoom
+ );
+ var newNorthWest = this.mmtouch.map.convertPixelToReal(
+ (new Point(this.mmtouch.map.getWidth(), 0)).plus(diff),
+ extentAfterZoom
+ );
+ var newExtent = new Mapbender.Extent(newSouthEast, newNorthWest);
+ this.mmtouch.map.setExtent(newExtent);
+ this.mmtouch.map.setMapRequest();
+ }
+ }
+ }
});
Modified: branches/mobile/http/javascripts/mod_selArea.js
===================================================================
--- branches/mobile/http/javascripts/mod_selArea.js 2011-08-02 12:00:04 UTC (rev 8043)
+++ branches/mobile/http/javascripts/mod_selArea.js 2011-08-02 12:12:12 UTC (rev 8044)
@@ -3,83 +3,200 @@
*
* Description:
* Zoom by rectangle
- *
+ *
* Files:
* - http/javascripts/mod_selArea.js
*
* SQL:
- * > <SQL for element>
- * >
- * > <SQL for element var>
+ * > <SQL for element>
+ * >
+ * > <SQL for element var>
*
* Help:
* http://www.mapbender.org/SelArea1
*
* Maintainer:
* http://www.mapbender.org/User:Christoph_Baudson
- *
+ *
* License:
* Copyright (c) 2009, Open Source Geospatial Foundation
- * This program is dual licensed under the GNU General Public License
- * and Simplified BSD license.
+ * This program is dual licensed under the GNU General Public License
+ * and Simplified BSD license.
* http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
*/
var that = this;
+
Mapbender.events.init.register(function () {
-
- var box;
- var map = Mapbender.modules[options.target];
-
- var button = new Mapbender.Button({
- domElement: that,
- over: options.src.replace(/_off/, "_over"),
- on: options.src.replace(/_off/, "_on"),
- off: options.src,
- name: options.id,
- go: function () {
- if (!map) {
- new Mb_exception(options.id + ": " +
- options.target + " is not a map!");
- return;
- }
-
- box = new Mapbender.Box({
- target: options.target
- });
- $(map.getDomElement()).css(
- "cursor", "crosshair"
- ).mousedown(function (e) {
- box.start(e);
- return false;
- }).mouseup(function (e) {
- box.stop(e, function (extent) {
- if (typeof extent === "undefined") {
- return false;
- }
- if (extent.constructor === Mapbender.Extent) {
- var xt = map.calculateExtent(extent);
- map.setMapRequest();
- }
- else if (extent.constructor === Mapbender.Point) {
- map.setCenter(extent);
- map.setMapRequest();
- }
- });
- return false;
- });
- },
- stop: function () {
- if (!map) {
- return;
- }
- $(map.getDomElement())
- .css("cursor", "default")
- .unbind("mousedown")
- .unbind("mouseup")
- .unbind("mousemove");
- box = null;
- }
- });
-});
\ No newline at end of file
+ var touch;
+ var box;
+ var map = Mapbender.modules[options.target];
+ var isTouchable = false;
+ try {
+ document.createEvent("TouchEvent");
+ isTouchable = true;
+ } catch(e){}
+ var button = new Mapbender.Button({
+ domElement: that,
+ over: options.src.replace(/_off/, "_over"),
+ on: options.src.replace(/_off/, "_on"),
+ off: options.src,
+ name: options.id,
+ go: function () {
+ if (!map) {
+ new Mb_exception(options.id + ": " +
+ options.target + " is not a map!");
+ return;
+ }
+ if(isTouchable) {
+ $(map.getDomElement()).css("cursor", "crosshair");
+
+ if ($.extend(map).defaultTouch) {
+ $.extend(map).defaultTouch.deactivate();
+ }
+ box = new Mapbender.BoxMobile({
+ target: options.target
+ });
+ touch = new selAreaTouch(map,$(map.getDomElement()), map.getDomElement(), box);
+ touch.activate();
+ } else {
+ box = new Mapbender.Box({
+ target: options.target
+ });
+
+ $(map.getDomElement()).css(
+ "cursor", "crosshair"
+ ).mousedown(function (e) {
+ box.start(e);
+ return false;
+ }).mouseup(function (e) {
+ box.stop(e, function (extent) {
+ if (typeof extent === "undefined") {
+ return false;
+ }
+ if (extent.constructor === Mapbender.Extent) {
+ var xt = map.calculateExtent(extent);
+ map.setMapRequest();
+ }
+ else if (extent.constructor === Mapbender.Point) {
+ map.setCenter(extent);
+ map.setMapRequest();
+ }
+ });
+ return false;
+ });
+ }
+ },
+ stop: function () {
+ if (!map) {
+ return;
+ }
+ if(isTouchable) {
+ $(map.getDomElement()).css("cursor", "default");
+ touch.deactivate();
+ touch = null;
+ box = null;
+ if ($.extend(map).defaultTouch) {
+ $.extend(map).defaultTouch.activate();
+ }
+ } else {
+ $(map.getDomElement())
+ .css("cursor", "default")
+ .unbind("mousedown")
+ .unbind("mouseup")
+ .unbind("mousemove");
+ box = null;
+ }
+ }
+ });
+ function selAreaTouch(map, $map, mapDom, box){
+ this.map = map;
+ this.$elm = $map;
+ this.elm = mapDom;
+ this.box = box;
+ this.startPos = null;
+ this.activate = function() {
+ this.elm.addEventListener("touchstart", touch.startTouch, true);
+ this.elm.addEventListener("touchmove", touch.moveTouch, true);
+ this.elm.addEventListener("touchend", touch.endTouch, true);
+ }
+ this.deactivate = function() {
+ this.elm.removeEventListener("touchstart", touch.startTouch, true);
+ this.elm.removeEventListener("touchmove", touch.moveTouch, true);
+ this.elm.removeEventListener("touchend", touch.endTouch, true);
+ }
+ this.startTouch = function(event) {
+ event.preventDefault();
+ var elm = findElement(event, "");
+ if (isSingleTouch(event)) {
+ touch.startPos = new Point(
+ event.touches[0].pageX - touch.$elm.offset().left,
+ event.touches[0].pageY - touch.$elm.offset().top);
+ var stopPos = new Point(touch.startPos.x, touch.startPos.y);
+ touch.box.start(touch.startPos, stopPos);
+ } else if (isMultiTouch(event)) {
+ var startPos = new Point(
+ event.touches[0].pageX - touch.$elm.offset().left,
+ event.touches[0].pageY - touch.$elm.offset().top);
+ var stopPos = new Point(
+ event.touches[1].pageX - touch.$elm.offset().left,
+ event.touches[1].pageY - touch.$elm.offset().top);
+ touch.box.start(startPos, stopPos);
+ }
+ return true;
+ }
+ this.moveTouch = function(event) {
+ event.preventDefault();
+ var elm = findElement(event, "");
+ if (isSingleTouch(event)) {
+ var stopPos = new Point(
+ event.touches[0].pageX - touch.$elm.offset().left,
+ event.touches[0].pageY - touch.$elm.offset().top);
+ touch.box.run(touch.startPos, stopPos);
+ } else if (isMultiTouch(event)) {
+ var startPos = new Point(
+ event.touches[0].pageX - touch.$elm.offset().left,
+ event.touches[0].pageY - touch.$elm.offset().top);
+ var stopPos = new Point(
+ event.touches[1].pageX - touch.$elm.offset().left,
+ event.touches[1].pageY - touch.$elm.offset().top);
+ touch.box.run(startPos, stopPos);
+ }
+ return true;
+ }
+ this.endTouch = function(event) {
+ return touch.box.stop(function (extent) {
+ if (typeof extent === "undefined") {
+ return false;
+ }
+ if (extent.constructor === Mapbender.Extent) {
+ var xt = touch.map.calculateExtent(extent);
+ touch.map.setMapRequest();
+ }
+ else if (extent.constructor === Mapbender.Point) {
+ touch.map.setCenter(extent);
+ touch.map.setMapRequest();
+ }
+ });
+ }
+
+ function findElement(event, tagName) {
+ var element = getElement(event);
+ while (element.parentNode && (!element.tagName ||
+ (element.tagName.toUpperCase() != tagName.toUpperCase()))){
+ element = element.parentNode;
+ return element;
+ }
+ }
+ function getElement(event) {
+ return event.target || event.srcElement;
+ }
+ function isSingleTouch (event) {
+ return event.touches && event.touches.length == 1;
+ }
+ function isMultiTouch(event) {
+ return event.touches && event.touches.length > 1;
+ }
+ }
+});
Modified: branches/mobile/http/javascripts/requestGeometryConstructor.js
===================================================================
--- branches/mobile/http/javascripts/requestGeometryConstructor.js 2011-08-02 12:00:04 UTC (rev 8043)
+++ branches/mobile/http/javascripts/requestGeometryConstructor.js 2011-08-02 12:12:12 UTC (rev 8044)
@@ -1,7 +1,7 @@
-/*
+/*
* $Id: requestGeometryConstructor.js 1882 2007-12-03 09:01:24Z verenadiewald $
* COPYRIGHT: (C) 2001 by ccgis. This program is free software under the GNU General Public
-* License (>=v2). Read the file gpl.txt that comes with Mapbender for details.
+* License (>=v2). Read the file gpl.txt that comes with Mapbender for details.
*/
//http://www.mapbender.org/index.php/requestGeometryConstructor.js
@@ -12,250 +12,424 @@
* @param {String} geomType type of the {@link RequestGeometryConstructor}
* @param {String} geomType target of the {@link RequestGeometryConstructor}
*/
- function RequestGeometryConstructor(geomTarget){
- /**
+function RequestGeometryConstructor(geomTarget){
+ /**
* geomTarget target of the {@link RequestGeometryConstructor}
*
* @type String
*/
+ this.geomTarget = geomTarget;
- this.geomTarget = geomTarget;
-
- var box = new Mapbender.Box({
- target: geomTarget
- });
-
- var that = this;
+ var that = this;
+ var ind = getMapObjIndexByName(this.geomTarget);
+ var myMapObj = mb_mapObj[ind];
+ var map_el = myMapObj.getDomElement();
- var ind = getMapObjIndexByName(this.geomTarget);
- var myMapObj = mb_mapObj[ind];
- var map_el = myMapObj.getDomElement();
- if(!map_el.ownerDocument.getElementById(myMapObj.elementName+"_request_geometry_polygon")){
- //create Box Elements
- var el_top = map_el.ownerDocument.createElement("div");
- el_top.style.position = "absolute";
- el_top.style.top = "0px";
- el_top.style.left = "0px";
- el_top.style.zIndex = "500";
- el_top.style.fontSize = "10px";
- el_top.id = myMapObj.elementName+"_request_geometry_polygon";
- map_el.appendChild(el_top);
- }
-
- if(!map_el.ownerDocument.getElementById(myMapObj.elementName+"_measure_display")){
- //create Box Elements
- var el_top = map_el.ownerDocument.createElement("div");
- el_top.style.position = "absolute";
- el_top.style.top = "0px";
- el_top.style.left = "0px";
- el_top.style.zIndex = "510";
- el_top.id = myMapObj.elementName+"_measure_display";
- map_el.appendChild(el_top);
- }
+ var box;
+ var touch;
+ var isTouchable = false;
+ try {
+ document.createEvent("TouchEvent");
+ isTouchable = true;
+ } catch(e){}
-
- this.getGeometry = function(queryType,callbackFunction){
- var target = this.geomTarget;
- s = new Snapping(this.geomTarget);
- callback = callbackFunction;
-
- var ind = getMapObjIndexByName(target);
- var el = mb_mapObj[ind].getDomElement();
- $(el).unbind("mousedown")
- .unbind("mouseover")
- .unbind("mouseup")
- .unbind("mousemove");
-
- if (queryType == "point") {
- queryGeom = new Geometry(geomType.point);
- $(el).mousedown(function (e) {
- realWorldPos = mapToReal(target,myMapObj.getMousePosition(e));
- queryGeom.addPoint(realWorldPos);
- callback(target, queryGeom);
- $(el).unbind("mousedown")
- .unbind("mouseover")
- .unbind("mouseup")
- .unbind("mousemove");
- queryGeom = null;
- });
- }
- else if (queryType == "polygon") {
- queryGeom = new Geometry(geomType.polygon);
- $(el).mousedown(function (e) {
- wfsSpatialRequestStart(e);
- }).mousemove(function (e) {
- wfsSpatialRequestRun(e);
- });
- }
- else if (queryType == "rectangle") {
- queryGeom = new Geometry(geomType.line);
- $(el).mousedown(function (e) {
- box.start(e);
- return false;
- }).mouseup(function (e) {
- var targetMap = Mapbender.modules[that.geomTarget];
- if (!targetMap) {
- return false;
- }
- box.stop(e, function (extent) {
- if (typeof extent === "undefined") {
- return false;
- }
- if (extent.constructor === Mapbender.Extent) {
- queryGeom = new Geometry(geomType.line);
- queryGeom.addPoint(extent.min);
- queryGeom.addPoint(extent.max);
- queryGeom.close();
- callback(that.geomTarget,queryGeom);
- $(el)
- .css("cursor", "default")
- .unbind("mousedown")
- .unbind("mouseup")
- .unbind("mousemove");
- box = null;
+ if(!map_el.ownerDocument.getElementById(myMapObj.elementName+"_request_geometry_polygon")){
- }
- });
- return false;
-
- });
- }
- else if (queryType == "extent") {
- queryGeom = new Geometry(geomType.line);
- var ind = getMapObjIndexByName(target);
- var p0 = mapToReal(target, new Point(0,0));
- var p1 = mapToReal(target, new Point(mb_mapObj[ind].width,mb_mapObj[ind].height));
- queryGeom.addPoint(p0);
- queryGeom.addPoint(p1);
- callback(target, queryGeom);
- $(el).unbind("mousedown")
- .unbind("mouseover")
- .unbind("mouseup")
- .unbind("mousemove");
+ //create Box Elements
+ var el_top = map_el.ownerDocument.createElement("div");
+ el_top.style.position = "absolute";
+ el_top.style.top = "0px";
+ el_top.style.left = "0px";
+ el_top.style.zIndex = "500";
+ el_top.style.fontSize = "10px";
+ el_top.id = myMapObj.elementName+"_request_geometry_polygon";
+ map_el.appendChild(el_top);
+ }
- queryGeom = null;
- }
-
- }
-
- var s;
- var callback;
-
- var wfsSpatialRequestStart = function(e){
- this.geomTarget = geomTarget;
- var that = this;
- var realWorldPos;
- if (s.isSnapped() == true) {
- realWorldPos = s.getSnappedPoint();
- s.clean();
- }
- else {
- realWorldPos = mapToReal(that.geomTarget,myMapObj.getMousePosition(e));
- }
- queryGeom.addPoint(realWorldPos);
-
- if (queryGeom.count() == 1) {
- s.add(queryGeom.get(0));
- }
- if (s.isSnapped() && queryGeom.count() >= 3 && queryGeom.get(-1).equals(queryGeom.get(0))) {
- queryGeom.close();
- callback(that.geomTarget,queryGeom);
- writeTag(myMapObj.frameName, myMapObj.elementName+"_request_geometry_polygon", "");
- writeTag(myMapObj.frameName, myMapObj.elementName+"_measure_display", "");
- var ind = getMapObjIndexByName("mapframe1");
- var el = mb_mapObj[ind].getDomElement();
- $(el).unbind("mousedown")
- .unbind("mouseover")
- .unbind("mouseup")
- .unbind("mousemove");
- queryGeom = null;
- return;
- }
- drawDashedLineExt();
- }
-
- var wfsSpatialRequestRun = function(e){
- this.geomTarget = geomTarget;
- var that = this;
- if (queryGeom.count() >= 3) {
- var pos = myMapObj.getMousePosition(e);
- s.check(pos);
- }
- }
-
- var drawDashedLineExt = function(e){
- this.geomTarget = geomTarget;
- var that = this;
- var ind = getMapObjIndexByName(that.geomTarget);
- var str_mPoints = "<div style='position:absolute;left:0px;top:0px' ><img src='"+mb_trans.src+"' width='"+mb_mapObj[ind].width+"' height='0'></div>";
- str_mPoints += "<div style='position:absolute;left:0px;top:0px' ><img src='"+mb_trans.src+"' width='0' height='"+mb_mapObj[ind].height+"'></div>";
- if (queryGeom != null) {
- for(var i=0; i<queryGeom.count(); i++){
- var pos = realToMap(that.geomTarget,queryGeom.get(i));
- str_mPoints += "<div style='font-size:1px;position:absolute;top:"+(pos.y-2)+"px;left:"+(pos.x-2)+"px;width:3px;height:3px;background-color:#ff0000'></div>";
- }
- if(queryGeom.count()>1){
- for(var k=1; k<queryGeom.count(); k++){
- var pos0 = realToMap(that.geomTarget,queryGeom.get(k));
- var pos1 = realToMap(that.geomTarget,queryGeom.get(k-1));
- str_mPoints += evaluateDashesExt(pos1,pos0,k);
- }
- }
- }
- writeTag(myMapObj.frameName, myMapObj.elementName+"_request_geometry_polygon", str_mPoints);
- }
-
- var evaluateDashesExt = function(p1,p0,count){
- this.geomTarget = geomTarget;
- var that = this;
- var ind = getMapObjIndexByName(that.geomTarget);
- var str_dashedLine = "";
- var d = p0.dist(p1);
- var n = Math.round(d);
- var s = p0.minus(p1).dividedBy(n);
- for(var i=1; i<n; i++){
- var currPoint = p1.plus(s.times(i)).minus(new Point(2,2)).round(0);
- if(currPoint.x >= 0 && currPoint.x <= mb_mapObj[ind].width && currPoint.y >= 0 && currPoint.y <= mb_mapObj[ind].height){
- str_dashedLine += "<div style='font-size:1px;position:absolute;top:"+currPoint.y+"px;left:"+currPoint.x+"px;width:3px;height:3px;background-color:#ff0000'></div>";
- }
- }
- return str_dashedLine;
- }
-
- var selAreaExtInit = function(e){
- mb_isBF = that.geomTarget;
- mb_zF = that.geomTarget;
- }
-
- var selAreaExtGet = function(e){
- selAreaExtSetValidClipping(mod_box_stop(e));
- mb_isBF = that.geomTarget;
- mb_zF = that.geomTarget;
- }
-
- var selAreaExtSetValidClipping = function(coords){
- this.geomTarget = geomTarget;
- var that = this;
- if (queryGeom != null) {
- queryGeom.addPoint(new Point(coords[0],coords[1]));
- queryGeom.addPoint(new Point(coords[2],coords[3]));
-
- if(queryGeom.count() == 2){
- callback(that.geomTarget,queryGeom);
- var ind = getMapObjIndexByName("mapframe1");
- var el = mb_mapObj[ind].getDomElement();
- $(el).unbind("mousedown")
- .unbind("mouseover")
- .unbind("mouseup")
- .unbind("mousemove");
- queryGeom = null;
- }
- else{
- callback(that.geomTarget,queryGeom);
- }
- }
- }
+ if(!map_el.ownerDocument.getElementById(myMapObj.elementName+"_measure_display")){
+ //create Box Elements
+ var el_top = map_el.ownerDocument.createElement("div");
+ el_top.style.position = "absolute";
+ el_top.style.top = "0px";
+ el_top.style.left = "0px";
+ el_top.style.zIndex = "510";
+ el_top.id = myMapObj.elementName+"_measure_display";
+ map_el.appendChild(el_top);
+ }
+
+
+ this.getGeometry = function(queryType,callbackFunction){
+ var target = this.geomTarget;
+ s = new Snapping(this.geomTarget);
+ callback = callbackFunction;
+
+ var ind = getMapObjIndexByName(target);
+ var el = mb_mapObj[ind].getDomElement();
+ $(el).unbind("mousedown")
+ .unbind("mouseover")
+ .unbind("mouseup")
+ .unbind("mousemove");
+ if (queryType == "point") {
+ if ($.extend(myMapObj).defaultTouch) {
+ $.extend(myMapObj).defaultTouch.deactivate();
+ }
+ queryGeom = new Geometry(geomType.point);
+ $(el).mousedown(function (e) {
+ realWorldPos = mapToReal(target,myMapObj.getMousePosition(e));
+ queryGeom.addPoint(realWorldPos);
+ callback(target, queryGeom);
+ $(el).unbind("mousedown")
+ .unbind("mouseover")
+ .unbind("mouseup")
+ .unbind("mousemove");
+ queryGeom = null;
+ if ($.extend(myMapObj).defaultTouch) {
+ $.extend(myMapObj).defaultTouch.activate();
+ }
+ });
+ }
+ else if (queryType == "polygon") {
+ if ($.extend(myMapObj).defaultTouch) {
+ $.extend(myMapObj).defaultTouch.deactivate();
+ }
+ queryGeom = new Geometry(geomType.polygon);
+ if(isTouchable){
+ $(el).mousedown(function (e) {
+ wfsSpatialRequestStart(e);
+ })
+ } else {
+ $(el).mousedown(function (e) {
+ wfsSpatialRequestStart(e);
+ }).mousemove(function (e) {
+ wfsSpatialRequestRun(e);
+ });
+ }
+
+ }
+ else if (queryType == "rectangle") {
+ if(isTouchable) {
+ if ($.extend(myMapObj).defaultTouch) {
+ $.extend(myMapObj).defaultTouch.deactivate();
+ }
+ box = new Mapbender.BoxMobile({
+ target: geomTarget
+ });
+ touch = new selAreaTouch(myMapObj,$(myMapObj.getDomElement()), myMapObj.getDomElement(), box);
+ touch.activate();
+ queryGeom = new Geometry(geomType.line);
+// $(el).mousedown(function (e) {
+// box.start(e);
+// return false;
+// }).mouseup(function (e) {
+// var targetMap = Mapbender.modules[that.geomTarget];
+// if (!targetMap) {
+// return false;
+// }
+// box.stop(e, function (extent) {
+// if (typeof extent === "undefined") {
+// return false;
+// }
+// if (extent.constructor === Mapbender.Extent) {
+// queryGeom = new Geometry(geomType.line);
+// queryGeom.addPoint(extent.min);
+// queryGeom.addPoint(extent.max);
+// queryGeom.close();
+// callback(that.geomTarget,queryGeom);
+//
+// $(el)
+// .css("cursor", "default")
+// .unbind("mousedown")
+// .unbind("mouseup")
+// .unbind("mousemove");
+// box = null;
+//
+// }
+// });
+// return false;
+//
+// });
+ } else {
+ box = new Mapbender.Box({
+ target: geomTarget
+ });
+ queryGeom = new Geometry(geomType.line);
+ $(el).mousedown(function (e) {
+ box.start(e);
+ return false;
+ }).mouseup(function (e) {
+ var targetMap = Mapbender.modules[that.geomTarget];
+ if (!targetMap) {
+ return false;
+ }
+ box.stop(e, function (extent) {
+ if (typeof extent === "undefined") {
+ return false;
+ }
+ if (extent.constructor === Mapbender.Extent) {
+ queryGeom = new Geometry(geomType.line);
+ queryGeom.addPoint(extent.min);
+ queryGeom.addPoint(extent.max);
+ queryGeom.close();
+ callback(that.geomTarget,queryGeom);
+
+ $(el)
+ .css("cursor", "default")
+ .unbind("mousedown")
+ .unbind("mouseup")
+ .unbind("mousemove");
+ box = null;
+
+ }
+ });
+ return false;
+
+ });
+ }
+
+ }
+ else if (queryType == "extent") {
+ queryGeom = new Geometry(geomType.line);
+ var ind = getMapObjIndexByName(target);
+ var p0 = mapToReal(target, new Point(0,0));
+ var p1 = mapToReal(target, new Point(mb_mapObj[ind].width,mb_mapObj[ind].height));
+ queryGeom.addPoint(p0);
+ queryGeom.addPoint(p1);
+ callback(target, queryGeom);
+ $(el).unbind("mousedown")
+ .unbind("mouseover")
+ .unbind("mouseup")
+ .unbind("mousemove");
+
+ queryGeom = null;
+ }
+
+ }
+
+ var s;
+ var callback;
+
+ var wfsSpatialRequestStart = function(e){
+ this.geomTarget = geomTarget;
+ var that = this;
+ var realWorldPos;
+ if(isTouchable) {
+ if (queryGeom.count() >= 3) {
+ var pos = myMapObj.getMousePosition(e);
+ s.check(pos);
+ }
+ }
+ if (s.isSnapped() == true) {
+ realWorldPos = s.getSnappedPoint();
+ s.clean();
+ }
+ else {
+ realWorldPos = mapToReal(that.geomTarget,myMapObj.getMousePosition(e));
+ }
+ queryGeom.addPoint(realWorldPos);
+
+ if (queryGeom.count() == 1) {
+ s.add(queryGeom.get(0));
+ }
+ if (s.isSnapped() && queryGeom.count() >= 3 && queryGeom.get(-1).equals(queryGeom.get(0))) {
+ queryGeom.close();
+ callback(that.geomTarget,queryGeom);
+ writeTag(myMapObj.frameName, myMapObj.elementName+"_request_geometry_polygon", "");
+ writeTag(myMapObj.frameName, myMapObj.elementName+"_measure_display", "");
+ var ind = getMapObjIndexByName("mapframe1");
+ var el = mb_mapObj[ind].getDomElement();
+ $(el).unbind("mousedown")
+ .unbind("mouseover")
+ .unbind("mouseup")
+ .unbind("mousemove");
+ queryGeom = null;
+ if ($.extend(myMapObj).defaultTouch) {
+ $.extend(myMapObj).defaultTouch.activate();
+ }
+ return;
+ }
+ drawDashedLineExt();
+ }
+
+ var wfsSpatialRequestRun = function(e){
+ this.geomTarget = geomTarget;
+ var that = this;
+ if (queryGeom.count() >= 3) {
+ var pos = myMapObj.getMousePosition(e);
+ s.check(pos);
+ }
+ }
+
+ var drawDashedLineExt = function(e){
+ this.geomTarget = geomTarget;
+ var that = this;
+ var ind = getMapObjIndexByName(that.geomTarget);
+ var str_mPoints = "<div style='position:absolute;left:0px;top:0px' ><img src='"+mb_trans.src+"' width='"+mb_mapObj[ind].width+"' height='0'></div>";
+ str_mPoints += "<div style='position:absolute;left:0px;top:0px' ><img src='"+mb_trans.src+"' width='0' height='"+mb_mapObj[ind].height+"'></div>";
+ if (queryGeom != null) {
+ for(var i=0; i<queryGeom.count(); i++){
+ var pos = realToMap(that.geomTarget,queryGeom.get(i));
+ str_mPoints += "<div style='font-size:1px;position:absolute;top:"+(pos.y-2)+"px;left:"+(pos.x-2)+"px;width:3px;height:3px;background-color:#ff0000'></div>";
+ }
+ if(queryGeom.count()>1){
+ for(var k=1; k<queryGeom.count(); k++){
+ var pos0 = realToMap(that.geomTarget,queryGeom.get(k));
+ var pos1 = realToMap(that.geomTarget,queryGeom.get(k-1));
+ str_mPoints += evaluateDashesExt(pos1,pos0,k);
+ }
+ }
+ }
+ writeTag(myMapObj.frameName, myMapObj.elementName+"_request_geometry_polygon", str_mPoints);
+ }
+
+ var evaluateDashesExt = function(p1,p0,count){
+ this.geomTarget = geomTarget;
+ var that = this;
+ var ind = getMapObjIndexByName(that.geomTarget);
+ var str_dashedLine = "";
+ var d = p0.dist(p1);
+ var n = Math.round(d);
+ var s = p0.minus(p1).dividedBy(n);
+ for(var i=1; i<n; i++){
+ var currPoint = p1.plus(s.times(i)).minus(new Point(2,2)).round(0);
+ if(currPoint.x >= 0 && currPoint.x <= mb_mapObj[ind].width && currPoint.y >= 0 && currPoint.y <= mb_mapObj[ind].height){
+ str_dashedLine += "<div style='font-size:1px;position:absolute;top:"+currPoint.y+"px;left:"+currPoint.x+"px;width:3px;height:3px;background-color:#ff0000'></div>";
+ }
+ }
+ return str_dashedLine;
+ }
+
+ var selAreaExtInit = function(e){
+ mb_isBF = that.geomTarget;
+ mb_zF = that.geomTarget;
+ }
+
+ var selAreaExtGet = function(e){
+ selAreaExtSetValidClipping(mod_box_stop(e));
+ mb_isBF = that.geomTarget;
+ mb_zF = that.geomTarget;
+ }
+
+ var selAreaExtSetValidClipping = function(coords){
+ this.geomTarget = geomTarget;
+ var that = this;
+ if (queryGeom != null) {
+ queryGeom.addPoint(new Point(coords[0],coords[1]));
+ queryGeom.addPoint(new Point(coords[2],coords[3]));
+
+ if(queryGeom.count() == 2){
+ callback(that.geomTarget,queryGeom);
+ var ind = getMapObjIndexByName("mapframe1");
+ var el = mb_mapObj[ind].getDomElement();
+ $(el).unbind("mousedown")
+ .unbind("mouseover")
+ .unbind("mouseup")
+ .unbind("mousemove");
+ queryGeom = null;
+ }
+ else{
+ callback(that.geomTarget,queryGeom);
+ }
+ }
+ }
+
+ function selAreaTouch(map, $map, mapDom, box){
+ this.map = map;
+ this.$elm = $map;
+ this.elm = mapDom;
+ this.box = box;
+ this.startPos = null;
+ this.activate = function() {
+ this.elm.addEventListener("touchstart", touch.startTouch, true);
+ this.elm.addEventListener("touchmove", touch.moveTouch, true);
+ this.elm.addEventListener("touchend", touch.endTouch, true);
+ }
+ this.deactivate = function() {
+ this.elm.removeEventListener("touchstart", touch.startTouch, true);
+ this.elm.removeEventListener("touchmove", touch.moveTouch, true);
+ this.elm.removeEventListener("touchend", touch.endTouch, true);
+ }
+ this.startTouch = function(event) {
+ event.preventDefault();
+ var elm = findElement(event, "");
+ if (isSingleTouch(event)) {
+ touch.startPos = new Point(
+ event.touches[0].pageX - touch.$elm.offset().left,
+ event.touches[0].pageY - touch.$elm.offset().top);
+ var stopPos = new Point(touch.startPos.x, touch.startPos.y);
+ touch.box.start(touch.startPos, stopPos);
+ } else if (isMultiTouch(event)) {
+ var startPos = new Point(
+ event.touches[0].pageX - touch.$elm.offset().left,
+ event.touches[0].pageY - touch.$elm.offset().top);
+ var stopPos = new Point(
+ event.touches[1].pageX - touch.$elm.offset().left,
+ event.touches[1].pageY - touch.$elm.offset().top);
+ touch.box.start(startPos, stopPos);
+ }
+ return true;
+ }
+ this.moveTouch = function(event) {
+ event.preventDefault();
+ var elm = findElement(event, "");
+ if (isSingleTouch(event)) {
+ var stopPos = new Point(
+ event.touches[0].pageX - touch.$elm.offset().left,
+ event.touches[0].pageY - touch.$elm.offset().top);
+ touch.box.run(touch.startPos, stopPos);
+ } else if (isMultiTouch(event)) {
+ var startPos = new Point(
+ event.touches[0].pageX - touch.$elm.offset().left,
+ event.touches[0].pageY - touch.$elm.offset().top);
+ var stopPos = new Point(
+ event.touches[1].pageX - touch.$elm.offset().left,
+ event.touches[1].pageY - touch.$elm.offset().top);
+ touch.box.run(startPos, stopPos);
+ }
+ return true;
+ }
+ this.endTouch = function(event) {
+ box = null;
+ touch.deactivate();
+ if ($.extend(myMapObj).defaultTouch) {
+ $.extend(myMapObj).defaultTouch.activate();
+ }
+ return touch.box.stop(
+ function (extent) {
+ if (typeof extent === "undefined") {
+ return false;
+ }
+ if (extent.constructor === Mapbender.Extent) {
+ queryGeom = new Geometry(geomType.line);
+ queryGeom.addPoint(extent.min);
+ queryGeom.addPoint(extent.max);
+ queryGeom.close();
+ callback(that.geomTarget,queryGeom);
+ }
+ }
+ );
+ touch.box = null;
+ touch = null;
+ }
+
+ function findElement(event, tagName) {
+ var element = getElement(event);
+ while (element.parentNode && (!element.tagName ||
+ (element.tagName.toUpperCase() != tagName.toUpperCase()))){
+ element = element.parentNode;
+ return element;
+ }
+ }
+ function getElement(event) {
+ return event.target || event.srcElement;
+ }
+ function isSingleTouch (event) {
+ return event.touches && event.touches.length == 1;
+ }
+ function isMultiTouch(event) {
+ return event.touches && event.touches.length > 1;
+ }
+ }
}
Modified: branches/mobile/http/plugins/mb_mobile.js
===================================================================
--- branches/mobile/http/plugins/mb_mobile.js 2011-08-02 12:00:04 UTC (rev 8043)
+++ branches/mobile/http/plugins/mb_mobile.js 2011-08-02 12:12:12 UTC (rev 8044)
@@ -10,4 +10,279 @@
} catch (e) {
return false;
}
-});
\ No newline at end of file
+});
+var defaultTouch;
+function MapTouch(map, $map, mapDom){
+ this.map = map;
+ this.$elm = $map;
+ this.elm = mapDom;
+
+ this.started = false;
+ this.startPos = 0, this.stopPos = 0;
+ this.timestamp = 0;
+ this.dblclick = false;
+ this.move = false;
+ this.pinch = false;
+ this.pinchObj = null;
+ this.activ = false;
+ defaultTouch = this;
+
+ this.activate = function() {
+ this.elm.addEventListener("touchstart", defaultTouch.startTouch, true);
+ this.elm.addEventListener("touchmove", defaultTouch.moveTouch, true);
+ this.elm.addEventListener("touchend", defaultTouch.endTouch, true);
+ this.activ = true;
+ };
+ this.activateTouchstart = function() {
+ this.elm.addEventListener("touchstart", defaultTouch.startTouch, true);
+ };
+ this.activateTouchmove = function() {
+ this.elm.addEventListener("touchmove", defaultTouch.moveTouch, true);
+ };
+ this.activateTouchend = function() {
+ this.elm.addEventListener("touchend", defaultTouch.endTouch, true);
+ };
+ this.setActivate = function() {
+ this.activ = true;
+ };
+
+
+ this.deactivate = function() {
+ this.elm.removeEventListener("touchstart", defaultTouch.startTouch, true);
+ this.elm.removeEventListener("touchmove", defaultTouch.moveTouch, true);
+ this.elm.removeEventListener("touchend", defaultTouch.endTouch, true);
+ this.activ = false;
+ };
+ this.deactivateTouchstart = function() {
+ this.elm.removeEventListener("touchstart", defaultTouch.startTouch, true);
+ };
+ this.deactivateTouchmove = function() {
+ this.elm.removeEventListener("touchmove", defaultTouch.moveTouch, true);
+ };
+ this.deactivateTouchend = function() {
+ this.elm.removeEventListener("touchend", defaultTouch.endTouch, true);
+ };
+ this.setDeactivate = function() {
+ this.activ = true;
+ };
+
+ this.isActiv = function() {
+ return this.activ;
+ }
+//
+// this.registerObject = function(obj) {
+// this.obj = obj;
+// alert(this.obj);
+// };
+
+ this.startTouch = function(event) {
+ event.preventDefault();
+ var elm = findElement(event, "");
+ if (isSingleTouch(event)) {
+ defaultTouch.startPos = new Mapbender.Point(
+ event.touches[0].pageX - defaultTouch.$elm.offset().left,
+ event.touches[0].pageY - defaultTouch.$elm.offset().top);
+ defaultTouch.stopPos = new Point(defaultTouch.startPos.x, defaultTouch.startPos.y);
+ var timestamp = new Date().getTime();
+ if (timestamp - defaultTouch.timestamp < 300) {
+ defaultTouch.dblclick = true;
+ }
+ defaultTouch.timestamp = timestamp;
+ } else if (isMultiTouch(event)) {
+ defaultTouch.dblclick = false;
+ defaultTouch.move = false;
+ defaultTouch.pinch = true;
+ defaultTouch.pinchObj = new Pinch(defaultTouch);
+ defaultTouch.pinchObj.pinchStart(event);
+ }
+ return true;
+ };
+ this.moveTouch = function(event) {
+ event.preventDefault();
+ var elm = findElement(event, "");
+ if (isSingleTouch(event)) {
+ defaultTouch.moveMapMove(event);
+ defaultTouch.move = true;
+ } else if(isMultiTouch(event)) {
+ defaultTouch.pinchObj.pinchRun(event);
+ }
+ return true;
+ };
+ this.endTouch = function(event) {
+ event.preventDefault();
+ var elm = findElement(event, "");
+ if (defaultTouch.dblclick) {
+ defaultTouch.zoomSingle(event);
+ defaultTouch.dblclick = false;
+ } else {
+ if (defaultTouch.move) {
+ defaultTouch.moveMapStop(event);
+ defaultTouch.move = false;
+ } else if (defaultTouch.pinch){
+ defaultTouch.pinchObj.pinchStop(event);
+ defaultTouch.pinch = false;
+ }
+ }
+ return true;
+ };
+
+ this.moveMapMove = function(event){
+ this.stopPos = new Mapbender.Point(
+ event.touches[0].pageX - this.$elm.offset().left,
+ event.touches[0].pageY - this.$elm.offset().top);
+ var dif = this.stopPos.minus(this.startPos);
+ this.map.moveMap(dif.x, dif.y);
+ };
+
+ this.moveMapStop = function(event){
+ var dif = this.stopPos.minus(this.startPos);
+ var mapCenter = new Mapbender.Point(
+ parseInt(parseInt(this.map.getWidth()) / 2),
+ parseInt(parseInt(this.map.getHeight()) / 2)
+ );
+ var center = mapCenter.minus(dif);
+ var realCenter = this.map.convertPixelToReal(center);
+ this.map.moveMap(dif.x, dif.y);
+ this.map.zoom(false, 1.0, realCenter);
+ this.startPos = null;
+ this.stopPos = null;
+ };
+
+ this.zoomSingle = function(event){
+ var pos = this.map.convertPixelToReal(this.stopPos);
+ var extentAfterZoom = this.map.calculateExtentAfterZoom(
+ true,
+ 2.0,
+ pos.x,
+ pos.y
+ );
+ var newPos = this.map.convertRealToPixel(
+ pos,
+ extentAfterZoom
+ );
+ var diff = newPos.minus(this.stopPos);
+
+ var newSouthEast = this.map.convertPixelToReal(
+ (new Point(0, this.map.getHeight())).plus(diff),
+ extentAfterZoom
+ );
+ var newNorthWest = this.map.convertPixelToReal(
+ (new Point(this.map.getWidth(), 0)).plus(diff),
+ extentAfterZoom
+ );
+ var newExtent = new Mapbender.Extent(newSouthEast, newNorthWest);
+ this.map.setExtent(newExtent);
+ this.map.setMapRequest();
+ };
+
+ function findElement(event, tagName) {
+ var element = getElement(event);
+ while (element.parentNode && (!element.tagName ||
+ (element.tagName.toUpperCase() != tagName.toUpperCase()))){
+ element = element.parentNode;
+ return element;
+ }
+ }
+
+ function getElement(event) {
+ return event.target || event.srcElement;
+ }
+
+ function isSingleTouch(event) {
+ return event.touches && event.touches.length == 1;
+ }
+
+ function isMultiTouch(event) {
+ return event.touches && event.touches.length > 1;
+ }
+
+ function Pinch(mmtouch){
+ this.mmtouch = mmtouch;
+ this.scale = 1;
+
+ this.pinchStart = function(event) {
+ this.pinchCenter = new Mapbender.Point(
+ parseInt((event.touches[0].pageX - this.mmtouch.$elm.offset().left +
+ event.touches[1].pageX - this.mmtouch.$elm.offset().left) / 2),
+ parseInt((event.touches[0].pageY - this.mmtouch.$elm.offset().top +
+ event.touches[1].pageY - this.mmtouch.$elm.offset().top) / 2));
+
+ this.pos0 = new Mapbender.Point(
+ event.touches[0].pageX - this.mmtouch.$elm.offset().left,
+ event.touches[0].pageY - this.mmtouch.$elm.offset().top);
+ this.pos1 = new Mapbender.Point(
+ event.touches[1].pageX - this.mmtouch.$elm.offset().left,
+ event.touches[1].pageY - this.mmtouch.$elm.offset().top);
+ this.startDist = Math.sqrt(
+ Math.pow(this.pos0.x - this.pos1.x, 2) +
+ Math.pow(this.pos0.y - this.pos1.y, 2));
+ }
+
+ this.pinchRun = function(event) {
+
+ this.lastPinchCenter = new Mapbender.Point(
+ parseInt((event.touches[0].pageX - this.mmtouch.$elm.offset().left +
+ event.touches[1].pageX - this.mmtouch.$elm.offset().left) / 2),
+ parseInt((event.touches[0].pageY - this.mmtouch.$elm.offset().top +
+ event.touches[1].pageY - this.mmtouch.$elm.offset().top) / 2));
+ // var dif = this.lastCenter.minus(this.center);
+ var pos0 = new Mapbender.Point(
+ event.touches[0].pageX - this.mmtouch.$elm.offset().left,
+ event.touches[0].pageY - this.mmtouch.$elm.offset().top);
+ var pos1 = new Mapbender.Point(
+ event.touches[1].pageX - this.mmtouch.$elm.offset().left,
+ event.touches[1].pageY - this.mmtouch.$elm.offset().top);
+ var dist = Math.sqrt(
+ Math.pow(pos0.x - pos1.x, 2) +
+ Math.pow(pos0.y - pos1.y, 2));
+ this.scale = dist / this.startDist;
+
+ var index = this.mmtouch.map.history.getCurrentIndex();
+ var width = parseInt(parseInt(this.mmtouch.$elm.css("width")) * this.scale);
+ var height = parseInt(parseInt(this.mmtouch.$elm.css("height")) * this.scale);
+ var leftAt = parseInt(this.lastPinchCenter.x * this.scale);
+ var topAt = parseInt(this.lastPinchCenter.y * this.scale);
+ var left = this.lastPinchCenter.x - leftAt;
+ var top = this.lastPinchCenter.y - topAt;
+ $("#" + this.mmtouch.map.elementName + "_request_" + (index) + " div img").css({
+ position: "absolute",
+ width: width + "px",
+ height: height + "px",
+ left: left + "px",
+ top: top + "px"
+ });
+ }
+ this.pinchStop = function(event) {
+ var pos = this.mmtouch.map.convertPixelToReal(this.lastPinchCenter);
+// var dist = this.startDist * this.scale;
+// var isZoomIn = false;
+// if (this.startDist - dist < 0){
+// isZoomIn = true;
+// }
+ var extentAfterZoom = this.mmtouch.map.calculateExtentAfterZoom(
+ true,
+ this.scale,
+ pos.x,
+ pos.y
+ );
+ var newPos = this.mmtouch.map.convertRealToPixel(
+ pos,
+ extentAfterZoom
+ );
+
+ var diff = newPos.minus(this.lastPinchCenter);
+
+ var newSouthEast = this.mmtouch.map.convertPixelToReal(
+ (new Point(0, this.mmtouch.map.getHeight())).plus(diff),
+ extentAfterZoom
+ );
+ var newNorthWest = this.mmtouch.map.convertPixelToReal(
+ (new Point(this.mmtouch.map.getWidth(), 0)).plus(diff),
+ extentAfterZoom
+ );
+ var newExtent = new Mapbender.Extent(newSouthEast, newNorthWest);
+ this.mmtouch.map.setExtent(newExtent);
+ this.mmtouch.map.setMapRequest();
+ }
+ }
+}
\ No newline at end of file
Modified: branches/mobile/http/plugins/mb_overview.js
===================================================================
--- branches/mobile/http/plugins/mb_overview.js 2011-08-02 12:00:04 UTC (rev 8043)
+++ branches/mobile/http/plugins/mb_overview.js 2011-08-02 12:12:12 UTC (rev 8044)
@@ -2,32 +2,32 @@
* Package: Overview
*
* Description:
- * Use the overview map to navigate the main map window. You can select a new
- * rectangle in the overview map, the details will be displayed in the main
- * map window. Recenter the main map window section by just clicking a new
- * position in the overview map (the scale will not change).
- *
+ * Use the overview map to navigate the main map window. You can select a new
+ * rectangle in the overview map, the details will be displayed in the main
+ * map window. Recenter the main map window section by just clicking a new
+ * position in the overview map (the scale will not change).
+ *
* Files:
* - http/javascripts/mod_overview.js
*
* SQL:
- * > INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment,
- * > e_title, e_element, e_src, e_attributes, e_left, e_top, e_width,
- * > e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file,
+ * > INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment,
+ * > e_title, e_element, e_src, e_attributes, e_left, e_top, e_width,
+ * > e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file,
* > e_mb_mod, e_target, e_requires, e_url) VALUES ('<app_id>','overview',
* > 2,1,'OverviewFrame','Overview','div','','',15,25,150,150,2,
* > 'overflow:hidden;',
* > '<div id="overview_maps" style="position:absolute;left:0px;right:0px;"></div>',
* > 'div','../plugins/mb_overview.js','mod_box1.js','mapframe1','mapframe1',
* > 'http://www.mapbender.org/index.php/Overview');
- * >
- * > INSERT INTO gui_element_vars (fkey_gui_id, fkey_e_id, var_name,
- * > var_value, context, var_type) VALUES ('<app_id>', 'overview',
+ * >
+ * > INSERT INTO gui_element_vars (fkey_gui_id, fkey_e_id, var_name,
+ * > var_value, context, var_type) VALUES ('<app_id>', 'overview',
* > 'overview_wms', '0', 'wms that shows up as overview' ,'var');
* >
- * > INSERT INTO gui_element_vars (fkey_gui_id, fkey_e_id, var_name,
- * > var_value, context, var_type) VALUES ('<app_id>', 'overview',
- * > 'skipWmsIfSrsNotSupported', '0',
+ * > INSERT INTO gui_element_vars (fkey_gui_id, fkey_e_id, var_name,
+ * > var_value, context, var_type) VALUES ('<app_id>', 'overview',
+ * > 'skipWmsIfSrsNotSupported', '0',
* > 'if set to 1, it skips the WMS request if the current SRS is not supported by the WMS; if set to 0, the WMS is always queried. Default is 0, because of backwards compatibility' ,
* > 'var');
*
@@ -36,27 +36,27 @@
*
* Maintainer:
* http://www.mapbender.org/User:Christoph_Baudson
- *
+ *
* Parameters:
* overview_wms - wms that shows up as overview
- * skipWmsIfSrsNotSupported - *[optional]* if set to 1, it skips the WMS
- * request if the current SRS is not supported by the WMS; if set
- * to 0, the WMS is always queried. Default is 0, because of
+ * skipWmsIfSrsNotSupported - *[optional]* if set to 1, it skips the WMS
+ * request if the current SRS is not supported by the WMS; if set
+ * to 0, the WMS is always queried. Default is 0, because of
* backwards compatibility
*
* License:
* Copyright (c) 2009, Open Source Geospatial Foundation
- * This program is dual licensed under the GNU General Public License
- * and Simplified BSD license.
+ * This program is dual licensed under the GNU General Public License
+ * and Simplified BSD license.
* http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
*/
if (typeof options.overview_wms === "undefined") {
- options.overview_wms = 0;
+ options.overview_wms = 0;
}
if (typeof options.enable_mouse === "undefined") {
- options.enable_mouse = 1;
+ options.enable_mouse = 1;
}
options.overview_wms = parseInt(options.overview_wms, 10);
@@ -70,22 +70,24 @@
var $this = $(this);
Mapbender.events.initMaps.register(function () {
-
+ var touch;
+ var isTouchable = false;
+ try {document.createEvent("TouchEvent"); isTouchable = true; } catch(e){}
$this.data("isMap", true);
$this.mapbender(new Mapbender.Map({
- id: options.id,
- width: options.width,
- height: options.height,
+ id: options.id,
+ width: options.width,
+ height: options.height,
wms: wms,
wmsIndexOverview: options.overview_wms
-
- }));
+ }));
+
map = Mapbender.modules[options.id];
map.isOverview = true;
- map.skipWmsIfSrsNotSupported =
+ map.skipWmsIfSrsNotSupported =
options.skipWmsIfSrsNotSupported === 1 ? true : false;
//
@@ -93,60 +95,162 @@
//
mb_mapObj.push(map);
- // add select area behaviour
- box = new Mapbender.Box({
- target: options.id
- });
-
- $(map.getDomElement()).mousedown(function (e) {
- if (options.enable_mouse == '0') {
- return false;
- }
- box.start(e);
- return false;
- }).mouseup(function (e) {
- var targetMap = Mapbender.modules[options.target];
- if (!targetMap) {
- return false;
- }
- box.stop(e, function (extent) {
- if (typeof extent === "undefined") {
- return false;
- }
- if (extent.constructor === Mapbender.Extent) {
- targetMap.calculateExtent(extent);
- targetMap.setMapRequest();
- }
- else if (extent.constructor === Mapbender.Point) {
- targetMap.setCenter(extent);
- targetMap.setMapRequest();
- }
- });
- return false;
- });
+ if (isTouchable) {
+ box = new Mapbender.BoxMobile({target: options.id});
+ touch = new mapTouch(map,$(map.getDomElement()), map.getDomElement(), box);
+ touch.activate();
+ } else {
+ // add select area behaviour
+ box = new Mapbender.Box({
+ target: options.id
+ });
+ $(map.getDomElement()).mousedown(function (e) {
+ if (options.enable_mouse == '0') {
+ return false;
+ }
+ box.start(e);
+ return false;
+ }).mouseup(function (e) {
+ var targetMap = Mapbender.modules[options.target];
+ if (!targetMap) {
+ return false;
+ }
+ box.stop(e, function (extent) {
+ if (typeof extent === "undefined") {
+ return false;
+ }
+ if (extent.constructor === Mapbender.Extent) {
+ targetMap.calculateExtent(extent);
+ targetMap.setMapRequest();
+ }
+ else if (extent.constructor === Mapbender.Point) {
+ targetMap.setCenter(extent);
+ targetMap.setMapRequest();
+ }
+ });
+ return false;
+ });
+ }
+
// if the setBackground module is active,
// the overview wms might be hidden.
// so we activate it here.
- var ovWmsArray = map.wms;
- if (typeof ovWmsArray !== "object" || ovWmsArray.length === 0) {
- return;
- }
- ovWmsArray[0].gui_wms_visible = 1;
+ var ovWmsArray = map.wms;
+ if (typeof ovWmsArray !== "object" || ovWmsArray.length === 0) {
+ return;
+ }
+ ovWmsArray[0].gui_wms_visible = 1;
+
+ function mapTouch(map, $map, mapDom, box){
+ this.map = map;
+ this.$elm = $map;
+ this.elm = mapDom;
+ this.box = box;
+ this.activate = function() {
+ this.elm.addEventListener("touchstart", touch.startTouch, true);
+ this.elm.addEventListener("touchmove", touch.moveTouch, true);
+ this.elm.addEventListener("touchend", touch.endTouch, true);
+ }
+ this.deactivate = function() {
+ this.elm.removeEventListener("touchstart", touch.startTouch, true);
+ this.elm.removeEventListener("touchmove", touch.moveTouch, true);
+ this.elm.removeEventListener("touchend", touch.endTouch, true);
+ }
+ this.startTouch = function(event) {
+ if (options.enable_mouse == '0') {
+ return false;
+ }
+ event.preventDefault();
+ var elm = findElement(event, "");
+ if (isSingleTouch(event)) {
+ touch.startPos = new Point(
+ event.touches[0].pageX - touch.$elm.offset().left,
+ event.touches[0].pageY - touch.$elm.offset().top);
+ var stopPos = new Point(touch.startPos.x, touch.startPos.y);
+ touch.box.start(touch.startPos, stopPos);
+ } else if (isMultiTouch(event)) {
+ var startPos = new Point(
+ event.touches[0].pageX - touch.$elm.offset().left,
+ event.touches[0].pageY - touch.$elm.offset().top);
+ var stopPos = new Point(
+ event.touches[1].pageX - touch.$elm.offset().left,
+ event.touches[1].pageY - touch.$elm.offset().top);
+ touch.box.start(startPos, stopPos);
+ }
+ return true;
+ }
+ this.moveTouch = function(event) {
+ event.preventDefault();
+ var elm = findElement(event, "");
+ if (isSingleTouch(event)) {
+ var stopPos = new Point(
+ event.touches[0].pageX - touch.$elm.offset().left,
+ event.touches[0].pageY - touch.$elm.offset().top);
+ touch.box.run(touch.startPos, stopPos);
+ } else if (isMultiTouch(event)) {
+ var startPos = new Point(
+ event.touches[0].pageX - touch.$elm.offset().left,
+ event.touches[0].pageY - touch.$elm.offset().top);
+ var stopPos = new Point(
+ event.touches[1].pageX - touch.$elm.offset().left,
+ event.touches[1].pageY - touch.$elm.offset().top);
+ touch.box.run(startPos, stopPos);
+ }
+ return true;
+ }
+ this.endTouch = function(event) {
+ var targetMap = Mapbender.modules[options.target];
+ if (!targetMap) {
+ return false;
+ }
+ return touch.box.stop(function (extent) {
+ if (typeof extent === "undefined") {
+ return false;
+ }
+ if (extent.constructor === Mapbender.Extent) {
+ targetMap.calculateExtent(extent);
+ targetMap.setMapRequest();
+ }
+ else if (extent.constructor === Mapbender.Point) {
+ targetMap.setCenter(extent);
+ targetMap.setMapRequest();
+ }
+ });
+ }
+ }
+
+ function findElement(event, tagName) {
+ var element = getElement(event);
+ while (element.parentNode && (!element.tagName ||
+ (element.tagName.toUpperCase() != tagName.toUpperCase()))){
+ element = element.parentNode;
+ return element;
+ }
+ }
+ function getElement(event) {
+ return event.target || event.srcElement;
+ }
+ function isSingleTouch (event) {
+ return event.touches && event.touches.length == 1;
+ }
+ function isMultiTouch(event) {
+ return event.touches && event.touches.length > 1;
+ }
});
//
-// update the rectangle indicating the current extent
+// update the rectangle indicating the current extent
// of the target map after each map request in the target
//
Mapbender.events.init.register(function () {
options.$target.mapbender(function () {
var targetMap = this;
targetMap.events.afterMapRequest.register(function () {
-
+
var min = map.convertRealToPixel(targetMap.extent.min);
var max = map.convertRealToPixel(targetMap.extent.max);
-
+
if (min.x < 0) {
min.x = 0;
}
@@ -172,8 +276,8 @@
max.y = centerY - 4;
}
var extent = new Mapbender.Extent(min, max);
-
+
box.draw(extent);
});
});
-});
+});
\ No newline at end of file
Modified: branches/mobile/http/plugins/mb_overview_mobile.js
===================================================================
--- branches/mobile/http/plugins/mb_overview_mobile.js 2011-08-02 12:00:04 UTC (rev 8043)
+++ branches/mobile/http/plugins/mb_overview_mobile.js 2011-08-02 12:12:12 UTC (rev 8044)
@@ -280,215 +280,4 @@
box.draw(extent);
});
});
-});
-//
-//Mapbender.BoxMobile = function (options) {
-// var map = (typeof options.target !== "undefined") ?
-// getMapObjByName(options.target) : null;
-//
-// var color = (typeof options.color !== "undefined") ?
-// options.color : "#ff0000";
-//
-// var isActive = false;
-// var top = 0;
-// var topSuffix = "_l_top";
-// var topNode;
-// var left = 0;
-// var leftSuffix = "_l_left";
-// var leftNode;
-// var bottom = 0;
-// var bottomSuffix = "_l_bottom";
-// var bottomNode;
-// var right = 0;
-// var rightSuffix = "_l_right";
-// var rightNode;
-//
-// var startPos = null;
-// var stopPos = null;
-//
-// var exists = false;
-// var that = this;
-//
-// this.start = function (pos) {
-// startPos = pos;
-// stopPos = new Point(startPos.x, startPos.y);
-// isActive = true;
-// top = startPos.y;
-// left = startPos.y;
-// bottom = startPos.y;
-// right = startPos.x;
-// return true;
-// };
-//
-// this.run = function (pos) {
-// if (pos !== null) {
-// stopPos = pos;
-// var width = map.width;
-// var height = map.height;
-//
-// if (startPos.x > stopPos.x) {
-// right = startPos.x;
-// left = stopPos.x;
-// }
-// else {
-// left = startPos.x;
-// right = stopPos.x;
-// }
-// if (startPos.y > stopPos.y) {
-// bottom = startPos.y;
-// top = stopPos.y;
-// }
-// else {
-// top = startPos.y;
-// bottom = stopPos.y;
-// }
-//
-// if (!startPos.equals(stopPos)) {
-// this.draw();
-// }
-// }
-// return true;
-// };
-//
-// this.stop = function (callback) {
-// hideElement(topNode);
-// hideElement(leftNode);
-// hideElement(rightNode);
-// hideElement(bottomNode);
-//
-// if (isActive) {
-// isActive = false;
-// if (typeof callback === "function") {
-// return callback(getExtent());
-// }
-// return getExtent();
-// }
-// isActive = false;
-// };
-//
-// var arrangeBox = function (node, left, top, right, bottom) {
-// var el = node.style;
-// el.height = Math.abs(bottom - top) + "px";
-// el.width = Math.abs(right - left) + "px";
-// el.top = top + "px";
-// el.left = left + "px";
-// };
-//
-// var displayElement = function (node) {
-// node.style.visibility = "visible";
-// };
-//
-// var hideElement = function (node) {
-// node.style.visibility = "hidden";
-// };
-//
-// var domElementsExist = function () {
-// if (!map) {
-// return;
-// }
-// return map.getDomElement(
-// ).ownerDocument.getElementById(
-// map.elementName + topSuffix
-// ) !== null;
-// };
-//
-// var createDomElements = function () {
-// if (!map) {
-// return;
-// }
-// var map_el = map.getDomElement();
-// topNode = map_el.ownerDocument.createElement("div");
-// topNode.style.position = "absolute";
-// topNode.style.top = "0px";
-// topNode.style.left = "0px";
-// topNode.style.width = "0px";
-// topNode.style.height = "0px";
-// topNode.style.overflow = "hidden";
-// // topNode.style.zIndex = parseInt(map_el.style.zIndex, 10) + 1;
-// topNode.style.zIndex = 100;
-// topNode.style.visibility = "visible";
-// topNode.style.cursor = "crosshair";
-// topNode.style.backgroundColor = color;
-//
-// leftNode = topNode.cloneNode(false);
-// rightNode = topNode.cloneNode(false);
-// bottomNode = topNode.cloneNode(false);
-//
-// topNode.id = map.elementName + topSuffix;
-// leftNode.id = map.elementName + leftSuffix;
-// rightNode.id = map.elementName + rightSuffix;
-// bottomNode.id = map.elementName + bottomSuffix;
-//
-// map_el.appendChild(topNode);
-// map_el.appendChild(leftNode);
-// map_el.appendChild(rightNode);
-// map_el.appendChild(bottomNode);
-//
-// exists = true;
-// };
-//
-// this.draw = function (extent) {
-// if (!map) {
-// return;
-// }
-// if (typeof extent === "object"
-// && extent.constructor === Mapbender.Extent) {
-//
-// left = extent.min.x;
-// right = extent.max.x;
-// bottom = extent.min.y;
-// top = extent.max.y;
-// }
-//
-// arrangeBox(topNode, left, top, right, top + 2);
-// arrangeBox(leftNode, left, top, left + 2, bottom);
-// arrangeBox(rightNode, right - 2, top, right, bottom);
-// arrangeBox(bottomNode, left, bottom - 2, right, bottom);
-// displayElement(topNode);
-// displayElement(leftNode);
-// displayElement(rightNode);
-// displayElement(bottomNode);
-// };
-//
-// var getExtent = function () {
-// if (!map) {
-// return null;
-// }
-// var x1 = startPos.x;
-// var x2 = stopPos.x;
-// var y1 = startPos.y;
-// var y2 = stopPos.y;
-//
-// var minx = x2;
-// var maxx = x1;
-// if(x1 < x2){
-// minx = x1;
-// maxx = x2;
-// }
-//
-// var miny = y1;
-// var maxy = y2;
-// if(y1 < y2){
-// miny = y2;
-// maxy = y1;
-// }
-//
-// // area or clickpoint ?
-// var posMin = map.convertPixelToReal(new Point(minx,miny));
-// if((maxx - minx) > 3 && (miny - maxy) > 3){
-// var posMax = map.convertPixelToReal(new Point(maxx,maxy));
-// return new Mapbender.Extent(posMin, posMax);
-// }
-// return posMin;
-// };
-//
-// if (!domElementsExist()) {
-// createDomElements();
-// }
-// else {
-// topNode = document.getElementById(map.elementName + topSuffix);
-// leftNode = document.getElementById(map.elementName + leftSuffix);
-// rightNode = document.getElementById(map.elementName + rightSuffix);
-// bottomNode = document.getElementById(map.elementName + bottomSuffix);
-// }
-//};
+});
\ No newline at end of file
Added: branches/mobile/log/mb_error_2011_08_02.log
===================================================================
--- branches/mobile/log/mb_error_2011_08_02.log (rev 0)
+++ branches/mobile/log/mb_error_2011_08_02.log 2011-08-02 12:12:12 UTC (rev 8044)
@@ -0,0 +1,41 @@
+2011.08.02, 13:11:56,ERROR: mb_validateSession.php: Invalid user:
+2011.08.02, 13:52:30,ERROR: connector: unable to load: http://wms1.ccgis.de/cgi-bin/mapserv?map=/data/umn/germany/germany.map&VERSION=1.1.1&REQUEST=GetFeatureInfo&SERVICE=WMS&LAYERS=Topographie,Grenze,Bundeslaender,Staedte,Postleitzahlbereiche,Bahnlinien,Strassen,Staedtepunkte,Staedtenamen,Bundeslaendernamen&QUERY_LAYERS=Postleitzahlbereiche,Staedtepunkte&WIDTH=525&HEIGHT=450&SRS=EPSG:4326&BBOX=-111.58333333333334,-80,85.58333333333334,89&STYLES=,,,,,,,,,&FORMAT=image/png&INFO_FORMAT=text/html&EXCEPTIONS=application/vnd.ogc.se_xml&X=103&Y=105&FEATURE_COUNT=100&=
+2011.08.02, 13:52:33,ERROR: connector: unable to load: http://wms1.ccgis.de/cgi-bin/mapserv?map=/data/umn/germany/germany.map&VERSION=1.1.1&REQUEST=GetFeatureInfo&SERVICE=WMS&LAYERS=Topographie,Grenze,Bundeslaender,Staedte,Postleitzahlbereiche,Bahnlinien,Strassen,Staedtepunkte,Staedtenamen,Bundeslaendernamen&QUERY_LAYERS=Postleitzahlbereiche,Staedtepunkte&WIDTH=525&HEIGHT=450&SRS=EPSG:4326&BBOX=-111.58333333333334,-80,85.58333333333334,89&STYLES=,,,,,,,,,&FORMAT=image/png&INFO_FORMAT=text/html&EXCEPTIONS=application/vnd.ogc.se_xml&X=395&Y=205&FEATURE_COUNT=100&=
+2011.08.02, 13:52:36,ERROR: connector: unable to load: http://wms1.ccgis.de/cgi-bin/mapserv?map=/data/umn/germany/germany.map&VERSION=1.1.1&REQUEST=GetFeatureInfo&SERVICE=WMS&LAYERS=Topographie,Grenze,Bundeslaender,Staedte,Postleitzahlbereiche,Bahnlinien,Strassen,Staedtepunkte,Staedtenamen,Bundeslaendernamen&QUERY_LAYERS=Postleitzahlbereiche,Staedtepunkte&WIDTH=525&HEIGHT=450&SRS=EPSG:4326&BBOX=-111.58333333333334,-80,85.58333333333334,89&STYLES=,,,,,,,,,&FORMAT=image/png&INFO_FORMAT=text/html&EXCEPTIONS=application/vnd.ogc.se_xml&X=352&Y=374&FEATURE_COUNT=100&=
+2011.08.02, 13:56:38,ERROR: connector: unable to load: http://wms1.ccgis.de/cgi-bin/mapserv?map=/data/umn/germany/germany.map&VERSION=1.1.1&REQUEST=GetFeatureInfo&SERVICE=WMS&LAYERS=Topographie,Grenze,Bundeslaender,Staedte,Postleitzahlbereiche,Bahnlinien,Strassen,Staedtepunkte,Staedtenamen,Bundeslaendernamen&QUERY_LAYERS=Postleitzahlbereiche,Staedtepunkte&WIDTH=525&HEIGHT=450&SRS=EPSG:4326&BBOX=-259,-180.5,71,102.5&STYLES=,,,,,,,,,&FORMAT=image/png&INFO_FORMAT=text/html&EXCEPTIONS=application/vnd.ogc.se_xml&X=302&Y=95&FEATURE_COUNT=100&=
+2011.08.02, 13:56:46,ERROR: connector: unable to load: http://wms1.ccgis.de/cgi-bin/mapserv?map=/data/umn/germany/germany.map&VERSION=1.1.1&REQUEST=GetFeatureInfo&SERVICE=WMS&LAYERS=Topographie,Grenze,Bundeslaender,Staedte,Postleitzahlbereiche,Bahnlinien,Strassen,Staedtepunkte,Staedtenamen,Bundeslaendernamen&QUERY_LAYERS=Postleitzahlbereiche,Staedtepunkte&WIDTH=525&HEIGHT=450&SRS=EPSG:4326&BBOX=-259,-180.5,71,102.5&STYLES=,,,,,,,,,&FORMAT=image/png&INFO_FORMAT=text/html&EXCEPTIONS=application/vnd.ogc.se_xml&X=356&Y=230&FEATURE_COUNT=100&=
+2011.08.02, 13:57:44,ERROR:
+2011.08.02, 13:57:44,ERROR:
+2011.08.02, 13:57:44,ERROR:
+2011.08.02, 13:58:05,ERROR: Javascript not found: MapTouch.js
+2011.08.02, 13:58:16,ERROR: Javascript not found: MapTouch.js
+2011.08.02, 14:08:27,ERROR:
+2011.08.02, 14:08:27,ERROR:
+2011.08.02, 14:08:27,ERROR:
+2011.08.02, 14:08:34,ERROR:
+2011.08.02, 14:08:34,ERROR:
+2011.08.02, 14:08:35,ERROR:
+2011.08.02, 14:08:40,ERROR:
+2011.08.02, 14:08:40,ERROR:
+2011.08.02, 14:08:40,ERROR:
+2011.08.02, 14:09:09,ERROR:
+2011.08.02, 14:09:09,ERROR:
+2011.08.02, 14:09:10,ERROR:
+2011.08.02, 14:09:28,ERROR:
+2011.08.02, 14:09:28,ERROR:
+2011.08.02, 14:09:28,ERROR:
+2011.08.02, 14:09:30,ERROR:
+2011.08.02, 14:09:30,ERROR:
+2011.08.02, 14:09:30,ERROR:
+2011.08.02, 14:09:53,ERROR:
+2011.08.02, 14:09:53,ERROR:
+2011.08.02, 14:09:54,ERROR:
+2011.08.02, 14:10:10,ERROR:
+2011.08.02, 14:10:11,ERROR:
+2011.08.02, 14:10:11,ERROR:
+2011.08.02, 14:10:20,ERROR:
+2011.08.02, 14:10:26,ERROR:
+2011.08.02, 14:10:26,ERROR:
+2011.08.02, 14:10:32,ERROR:
+2011.08.02, 14:10:32,ERROR:
+2011.08.02, 14:10:32,ERROR:
More information about the Mapbender_commits
mailing list