X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=view%2Ftheme%2Fdiabook%2Fjs%2Fjquery.mapquery.mqMousePosition.js;h=9f7e151ff19cf162e95ed200d5e2bc2e1bc364f6;hb=24b58af68938558baa2ddc6809401ec528ff1176;hp=d4370bfe49f9abb659911b18760cc09f333de545;hpb=f2e648d62fe7cafb9a55c7505687ea4d1c294778;p=friendica.git diff --git a/view/theme/diabook/js/jquery.mapquery.mqMousePosition.js b/view/theme/diabook/js/jquery.mapquery.mqMousePosition.js index d4370bfe49..9f7e151ff1 100644 --- a/view/theme/diabook/js/jquery.mapquery.mqMousePosition.js +++ b/view/theme/diabook/js/jquery.mapquery.mqMousePosition.js @@ -44,8 +44,8 @@ $.widget("mapQuery.mqMousePosition", { // The number of decimals for the coordinates // default: 2 - // TODO: JCB20110630 use dynamic precision based on the pixel - // resolution, no need to configure precision + // TODO: JCB20110630 use dynamic precision based on the pixel + // resolution, no need to configure precision precision: 2, // The label of the x-value @@ -57,51 +57,36 @@ $.widget("mapQuery.mqMousePosition", { }, _create: function() { - var map; - var self = this; - var element = this.element; - var mousepos; - //get the mapquery object - map = $(this.options.map).data('mapQuery'); - - map.bind("mousemove", - {widget:self,map:map}, - self._onMouseMove); - + this.map = $(this.options.map).data('mapQuery'); - $.tmpl('mqMousePosition',{ - mouseposition:mousepos - }).appendTo(element); + this.map.element.bind('mousemove', {widget: this}, this._onMousemove); + $.tmpl('mqMousePosition', {}).appendTo(this.element); }, _destroy: function() { - this.element.removeClass(' ui-widget ui-helper-clearfix ' + + this.element.removeClass('ui-widget ui-helper-clearfix ' + 'ui-corner-all') .empty(); }, - _mouseMoved: function(data, element, map) { - var x = data.layerX; - var y = data.layerY; - var mapProjection = map.options.projection; - var displayProjection = map.options.projection; + _onMousemove: function(evt) { + var self = evt.data.widget; + var x = evt.pageX; + var y = evt.pageY; + var mapProjection = new OpenLayers.Projection(self.map.projection); + var displayProjection = new OpenLayers.Projection( + self.map.displayProjection); + var pos = self.map.olMap.getLonLatFromLayerPx( + new OpenLayers.Pixel(x, y)); //if the coordinates should be displayed in something else, - //set them via the map displayProjection option - var pos = map.olMap.getLonLatFromLayerPx(new OpenLayers.Pixel(x,y)); - if(map.options.displayProjection) { - displayProjection = map.options.displayProjection; - pos=pos.transform( - new OpenLayers.Projection(mapProjection), - new OpenLayers.Projection(displayProjection)); + //set them via the map displayProjection option + if(!mapProjection.equals(self.map.displayProjection)) { + pos = pos.transform(mapProjection, displayProjection); } - $("#id_diabook_ELPosX", element).val( - this.options.x+pos.lon.toFixed(this.options.precision)); - $("#id_diabook_ELPosY", element).val( - this.options.y+pos.lat.toFixed(this.options.precision)); - }, - - _onMouseMove: function(evt, data) { - evt.data.widget._mouseMoved(data,evt.data.control,evt.data.map); + $("#id_diabook_ELPosX", document.element).val( + self.options.x + pos.lon.toFixed(self.options.precision)); + $("#id_diabook_ELPosY", document.element).val( + self.options.y + pos.lat.toFixed(self.options.precision)); } }); })(jQuery);