diff options
author | friendica <info@friendica.com> | 2012-05-06 19:56:27 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2012-05-06 19:56:27 -0700 |
commit | 8a10af3bce54141be7e03a96f7a9c2df28c7fa5b (patch) | |
tree | 78aa6c1ed4fbc3d8d679b552c2bfc9bf690e1cf3 /view/theme/diabook/js/jquery.mapquery.mqMousePosition.js | |
parent | 57920849c4138920b5715931a268dd2a55c76003 (diff) | |
parent | e417f083b53c5759346bcfcc451b0d89696788aa (diff) | |
download | volse-hubzilla-8a10af3bce54141be7e03a96f7a9c2df28c7fa5b.tar.gz volse-hubzilla-8a10af3bce54141be7e03a96f7a9c2df28c7fa5b.tar.bz2 volse-hubzilla-8a10af3bce54141be7e03a96f7a9c2df28c7fa5b.zip |
Merge https://github.com/friendica/friendica into pull
Diffstat (limited to 'view/theme/diabook/js/jquery.mapquery.mqMousePosition.js')
-rw-r--r-- | view/theme/diabook/js/jquery.mapquery.mqMousePosition.js | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/view/theme/diabook/js/jquery.mapquery.mqMousePosition.js b/view/theme/diabook/js/jquery.mapquery.mqMousePosition.js new file mode 100644 index 000000000..54d0c5309 --- /dev/null +++ b/view/theme/diabook/js/jquery.mapquery.mqMousePosition.js @@ -0,0 +1,107 @@ +/* Copyright (c) 2011 by MapQuery Contributors (see AUTHORS for + * full list of contributors). Published under the MIT license. + * See https://github.com/mapquery/mapquery/blob/master/LICENSE for the + * full text of the license. */ + +/** +#jquery.mapquery.mqMousePosition.js +The file containing the mqMousePosition Widget + +### *$('selector')*.`mqMousePosition([options])` +_version added 0.1_ +####**Description**: create a widget to show the location under the mouse pointer + + + **options** + - **map**: the mapquery instance + - **precision**: the number of decimals (default 2) + - **x**: the label for the x-coordinate (default x) + - **y**: the label for the y-coordinate (default y) + + +>Returns: widget + + +The mqMousePosition allows us to show the coordinates under the mouse pointer + + + $('#mousepointer').mqMousePointer({ + map: '#map' + }); + + */ +(function($) { +$.template('mqMousePosition', + '<div class="mq-mouseposition ui-widget ui-helper-clearfix ">'+ + '<span class="ui-widget-content ui-helper-clearfix ui-corner-all ui-corner-all">'+ + '<div id="mq-mouseposition-x" class="mq-mouseposition-coordinate">'+ + '</div><div id="mq-mouseposition-y" class="mq-mouseposition-coordinate">'+ + '</div></div></span>'); + +$.widget("mapQuery.mqMousePosition", { + options: { + // The MapQuery instance + map: undefined, + + // The number of decimals for the coordinates + // default: 2 + // TODO: JCB20110630 use dynamic precision based on the pixel + // resolution, no need to configure precision + precision: 2, + + // The label of the x-value + // default: 'x' + x: 'x', + // The label of the y-value + // default: 'y' + y: 'y' + + }, + _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); + + + $.tmpl('mqMousePosition',{ + mouseposition:mousepos + }).appendTo(element); + + }, + _destroy: function() { + 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; + //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)); + } + $("#mq-mouseposition-x", element).html( + this.options.x+': '+pos.lon.toFixed(this.options.precision)); + $("#mq-mouseposition-y", element).html( + this.options.y+': '+pos.lat.toFixed(this.options.precision)); + }, + + _onMouseMove: function(evt, data) { + evt.data.widget._mouseMoved(data,evt.data.control,evt.data.map); + } +}); +})(jQuery); |