Skip to content

Commit

Permalink
merged with master
Browse files Browse the repository at this point in the history
  • Loading branch information
stvno committed Jul 28, 2011
2 parents 73dfcbb + 89d63a7 commit 49af368
Show file tree
Hide file tree
Showing 14 changed files with 274 additions and 155 deletions.
1 change: 1 addition & 0 deletions THANKS
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ suggesting improvements or submitting changes. Some of these people are:
* Christian Wygoda
* Drew Wells
* Christian Kaatz
* Justin Penka

For a list of authors see the `AUTHORS` file.
2 changes: 1 addition & 1 deletion demo/google.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<!--This example needs googlemaps API-->
<script src="http://maps.google.com/maps/api/js?v=3.5&amp;sensor=false" type="text/javascript"></script>
<!--This example needs googleNG layer from openlayers which is not yet available in the releases-->
<script src="http://openlayers.org/dev/OpenLayers.js" type="text/javascript"></script>
<script src="http://mapquery.org/0.1/lib/openlayers/OpenLayers.js" type="text/javascript"></script>
<script src="../lib/jquery/jquery-1.4.4.js" type="text/javascript"></script>
<script src="../src/jquery.mapquery.core.js" type="text/javascript"></script>

Expand Down
1 change: 1 addition & 0 deletions demo/widgets/mqFeatureInfo.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
label: 'Polygons',
url: '../data/poly.json'
}],
projection:'EPSG:4326',
maxExtent: [0, -90, 160, 90]
});
//map.data('mapQuery').center({zoom:2});
Expand Down
3 changes: 2 additions & 1 deletion demo/widgets/mqPopup.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<title>MapQuery widget example</title>
<link rel="stylesheet" href="../../lib/jquery/themes/base/jquery-ui.css" type="text/css" media="all" />
<link rel="stylesheet" type="text/css" href="../style/style.css" />
<script src="../../lib/openlayers/OpenLayers.js" type="text/javascript"></script>
<script src="../../lib/openlayers/lib/OpenLayers.js" type="text/javascript"></script>
<script src="../../lib/jquery/jquery-1.4.4.js" type="text/javascript"></script>
<script src="../../lib/jquery/ui/jquery-ui.js" type="text/javascript"></script>
<script src="../../lib/jquery/jquery.tmpl.js" type="text/javascript"></script>
Expand All @@ -23,6 +23,7 @@
label: 'Polygons',
url: '../data/poly.json'
}],
projection:'EPSG:4326',
maxExtent: [0, -90, 160, 90]
});
$('#popup').mqPopup({
Expand Down
4 changes: 3 additions & 1 deletion lib/openlayers.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ OpenLayers/Layer/XYZ.js
OpenLayers/Layer/Bing.js
OpenLayers/Layer/WMS.js
OpenLayers/Layer/Vector.js
OpenLayers/Layer/GoogleNG.js
OpenLayers/Layer/Google.js
OpenLayers/Layer/Google/v3.js
OpenLayers/Layer/WMTS.js
OpenLayers/Control/ArgParser.js
OpenLayers/Control/Navigation.js
Expand All @@ -20,6 +21,7 @@ OpenLayers/Control/Attribution.js
OpenLayers/Control/SelectFeature.js
OpenLayers/Control/DrawFeature.js
OpenLayers/Control/ModifyFeature.js
OpenLayers/Control/KeyboardDefaults.js
OpenLayers/Control/OverviewMap.js
OpenLayers/Handler/Point.js
OpenLayers/Handler/Path.js
Expand Down
219 changes: 141 additions & 78 deletions src/jquery.mapquery.core.js

Large diffs are not rendered by default.

25 changes: 15 additions & 10 deletions src/jquery.mapquery.legend.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#jquery.mapquery.legend.js
A plugin on mapquery.core to add a legend to a layer. It will check if the layer
is within a valid extent and zoom range. And if not will return an error message.
*/
*/

(function($, MQ) {
$.extend( $.fn.mapQuery.defaults.layer.all, {
Expand All @@ -30,12 +30,13 @@ _version added 0.1_
The `.legend()` function allows us to attach a legend image to a layer. It will
also check if the layer is not visible due to wrong extent or zoom level. It will
return an error message which can be used to notify the user.
also check if the layer is not visible due to wrong extent or zoom level.
It will return an error message which can be used to notify the user.
var legend = layer.legend(); //get the current legend
layer.legend({url:'legendimage.png'}) //set the legend url to legendimage.png
//set the legend url to legendimage.png
layer.legend({url:'legendimage.png'})
*/
//get/set the legend object
Expand All @@ -61,20 +62,24 @@ return an error message which can be used to notify the user.
_checkBox: function(center){
var maxExtent = this.options.maxExtent;
if(maxExtent!==undefined) {
var mapBounds = new OpenLayers.Bounds(center.box[0],center.box[1],center.box[2],center.box[3]);
var layerBounds = new OpenLayers.Bounds(maxExtent[0],maxExtent[1],maxExtent[2],maxExtent[3]);
var mapBounds = new OpenLayers.Bounds(
center.box[0],center.box[1],center.box[2],center.box[3]);
var layerBounds = new OpenLayers.Bounds(
maxExtent[0],maxExtent[1],maxExtent[2],maxExtent[3]);
var inside = layerBounds.containsBounds(mapBounds, true);
this.options.legend.msg = inside?'':LEGEND_ERRORS[2];
}
},
//Check if the layer has a minimum or maximum zoom set and if the current zoom
//is outside these settings, set the legend.msg accordingly
//Check if the layer has a minimum or maximum zoom set and if the
//current zoom is outside these settings, set the legend.msg accordingly
_checkZoom: function(center){
var zoom = center.zoom;
var maxZoom = this.options.maxZoom;
var minZoom = this.options.minZoom;
this.options.legend.msg=(maxZoom!==undefined&&maxZoom<zoom)? LEGEND_ERRORS[0]:'';
this.options.legend.msg=(minZoom!==undefined&&minZoom>zoom)? LEGEND_ERRORS[1]:'';
this.options.legend.msg=(
maxZoom!==undefined&&maxZoom<zoom)? LEGEND_ERRORS[0]:'';
this.options.legend.msg=(
minZoom!==undefined&&minZoom>zoom)? LEGEND_ERRORS[1]:'';
}

});
Expand Down
10 changes: 6 additions & 4 deletions src/jquery.mapquery.mqFeatureInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ _version added 0.1_
+ **options**
- **map**: the mapquery instance
- **contents**: A function that returns HTML to be put into the popup. It has one
argument, which is the OpenLayers feature that was selected.
- **title**: Title that will be displayed at the top of the feature info (default: Feature information)
- **contents**: A function that returns HTML to be put into the popup.
It has one argument, which is the OpenLayers feature that was selected.
- **title**: Title that will be displayed at the top of the feature
info (default: Feature information)
>Returns: widget
The mqFeatureInfo widget allows us to display the information of a selected feature.
The mqFeatureInfo widget allows us to display the information
of a selected feature.
$('#featureinfo').mqFeatureInfo({
Expand Down
8 changes: 5 additions & 3 deletions src/jquery.mapquery.mqLayerControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ It is likely that the two will be merged in the future
(function($) {
$.template('mqLayerControl',
'<li id="mq-layercontrol-${id}" class="mq-layercontrol ui-widget-content ui-helper-clearfix ui-corner-all">'+
'<span><div class="ui-icon ui-icon-arrowthick-2-n-s"></div><div class="mq-layercontrol-label">${label}</div>' +
'<span><div class="ui-icon ui-icon-arrowthick-2-n-s"></div>'+
'<div class="mq-layercontrol-label">${label}</div>' +
'<button class="mq-layercontrol-delete">Delete</button>' +
'<input type="checkbox" class="mq-layercontrol-visibility" id="${id}-visibility" checked="${visible}" />'+
'<label for="${id}-visibility">Visible</label></span>'+
Expand Down Expand Up @@ -123,7 +124,8 @@ $.widget("mapQuery.mqLayerControl", {
evt.data.widget._add(evt.data.control,layer);
},

// if _remove is called from the mqRemoveLayer event it means that the layer is already removed, so set removed to true
// if _remove is called from the mqRemoveLayer event it means that the
// layer is already removed, so set removed to true
_remove: function(id, removed) {
var controlId = "#mq-layercontrol-"+id;
var control = $(controlId);
Expand All @@ -138,4 +140,4 @@ $.widget("mapQuery.mqLayerControl", {
}

});
})(jQuery);
})(jQuery);
50 changes: 31 additions & 19 deletions src/jquery.mapquery.mqLayerManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ _version added 0.1_
+ **options**:
- **map**: the mapquery instance
- **title**: Title that will be displayed at the top of the layer manager (default: Layer Manager)
- **title**: Title that will be displayed at the top of the
layer manager (default: Layer Manager)
>Returns: widget
>Requires: jquery.mapquery.legend.js
The mqLayerManager allows us to control the order, opacity and visibility of layers.
We can also remove layers. It also shows the legend of the layer if available and
the error messages provided by the legend plugin. It listens to layerchange event
for order, transparancy and opacity changes. It listens to addlayer and removelayer
events to keep track which layers are on the map.
The mqLayerManager allows us to control the order, opacity and visibility
of layers. We can also remove layers. It also shows the legend of the layer if
available and the error messages provided by the legend plugin. It listens to
layerchange event for order, transparancy and opacity changes. It listens to
addlayer and removelayer events to keep track which layers are on the map.
$('#layermanager').mqLayerManager({map:'#map'});
Expand All @@ -39,12 +40,15 @@ $.template('mqLayerManager',

$.template('mqLayerManagerElement',
'<div class="mq-layermanager-element ui-widget-content ui-corner-all" id="mq-layermanager-element-${id}">'+
'<div class="mq-layermanager-element-header ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix"><span class="mq-layermanager-label ui-dialog-title">${label}</span>'+
'<a class="ui-dialog-titlebar-close ui-corner-all" href="#" role="button"><span class="ui-icon ui-icon-closethick">close</span></a></div>'+
'<div class="mq-layermanager-element-header ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix">'+
'<span class="mq-layermanager-label ui-dialog-title">${label}</span>'+
'<a class="ui-dialog-titlebar-close ui-corner-all" href="#" role="button">'+
'<span class="ui-icon ui-icon-closethick">close</span></a></div>'+
'<div class="mq-layermanager-element-content">'+
'<div class="mq-layermanager-element-visibility">'+
'<input type="checkbox" class="mq-layermanager-element-vischeckbox" id="${id}-visibility" {{if visible}}checked="${visible}"{{/if}} />'+
'<div class="mq-layermanager-element-slider-container"><div class="mq-layermanager-element-slider"></div></div>'+
'<div class="mq-layermanager-element-slider-container">'+
'<div class="mq-layermanager-element-slider"></div></div>'+
'</div>'+
'<div class="mq-layermanager-element-legend">'+
'{{if imgUrl}}'+
Expand Down Expand Up @@ -95,13 +99,14 @@ $.widget("mapQuery.mqLayerManager", {
}
});

//these layers are already added to the map as such won't trigger and event,
//we call the draw function directly
//these layers are already added to the map as such won't trigger
//and event, we call the draw function directly
$.each(map.layers().reverse(), function(){
self._layerAdded(lmElement, this);
});

element.delegate('.mq-layermanager-element-vischeckbox', 'change', function() {
element.delegate('.mq-layermanager-element-vischeckbox',
'change',function() {
var checkbox = $(this);
var element = checkbox.parents('.mq-layermanager-element');
var layer = element.data('layer');
Expand Down Expand Up @@ -242,24 +247,31 @@ $.widget("mapQuery.mqLayerManager", {
},

_layerVisible: function(widget, layer) {
var layerElement = widget.element.find('#mq-layermanager-element-'+layer.id);
var checkbox = layerElement.find('.mq-layermanager-element-vischeckbox');
var layerElement =
widget.element.find('#mq-layermanager-element-'+layer.id);
var checkbox =
layerElement.find('.mq-layermanager-element-vischeckbox');
checkbox[0].checked = layer.visible();
//update the opacity slider as well
var slider = layerElement.find('.mq-layermanager-element-slider');
var value = layer.visible()?layer.opacity()*100: 0;
slider.slider('value',value);

//update legend image
layerElement.find('.mq-layermanager-element-legend img').css({visibility:layer.visible()?true:'hidden'});
layerElement.find('.mq-layermanager-element-legend img').css(
{visibility:layer.visible()?true:'hidden'});
},

_layerOpacity: function(widget, layer) {
var layerElement = widget.element.find('#mq-layermanager-element-'+layer.id);
var slider = layerElement.find('.mq-layermanager-element-slider');
var layerElement = widget.element.find(
'#mq-layermanager-element-'+layer.id);
var slider = layerElement.find(
'.mq-layermanager-element-slider');
slider.slider('value',layer.opacity()*100);
//update legend image
layerElement.find('.mq-layermanager-element-legend img').css({opacity:layer.opacity()});
layerElement.find(
'.mq-layermanager-element-legend img').css(
{opacity:layer.opacity()});
},

_moveEnd: function (widget,lmElement,map) {
Expand Down Expand Up @@ -302,4 +314,4 @@ $.widget("mapQuery.mqLayerManager", {
evt.data.widget._moveEnd(evt.data.widget,evt.data.control,evt.data.map);
}
});
})(jQuery);
})(jQuery);
24 changes: 16 additions & 8 deletions src/jquery.mapquery.mqMousePosition.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
$.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>');
'<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: {
Expand All @@ -17,7 +18,9 @@ $.widget("mapQuery.mqMousePosition", {

// The number of decimals for the coordinates
// default: 2
precision: 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
// default: 'x'
Expand Down Expand Up @@ -56,18 +59,23 @@ $.widget("mapQuery.mqMousePosition", {
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
//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));
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));
$("#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);
})(jQuery);
Loading

0 comments on commit 49af368

Please sign in to comment.