Permalink
Browse files

Adding new controls and Modest Maps code for 1.1.0

  • Loading branch information...
1 parent f22a88e commit 046add470ca68cc6bf385ff34315cd9aa2ff9814 @tmcw tmcw committed Apr 8, 2011
View
@@ -12,20 +12,28 @@ implementation of the [MBTiles interaction specification](https://github.com/map
* `wax.ol.Interaction`
* `wax.ol.Legend`
+* `wax.ol.Embedder`
+* `wax.ol.Switcher`
#### Google Maps API v3
* `wax.g.Controls`
* `wax.g.MapType`
* `wax.g.mapBoxLogo`
+#### Modest Maps
+
+* `.interaction()`
+* `.zoomer()`
+* `.legend()`
+
#### Lib
* `jquery.jsonp-2.1.4.js`, [from jquery-jsonp](http://code.google.com/p/jquery-jsonp/)
#### Records
-The main usage of mapping frameworks through Wax is via records. Records are pure JSON objects that have a 1:1 representation with function Javascript code, but, unlike imperative code, can be stored and manipulated as configuration. Records are tested with [polymaps](http://polymaps.org), [openlayers](http://openlayers.org/) and Google Maps API v3, but the system (`/lib/record.js`) is generalized beyond mapping tools of any sort, to exist as a basic Javascript AST interpreter.
+The main usage of mapping frameworks through Wax is via records. Records are pure JSON objects that have a 1:1 representation with function Javascript code, but, unlike imperative code, can be stored and manipulated as configuration. Records are tested with [polymaps](http://polymaps.org), [openlayers](http://openlayers.org/), [Modest Maps](https://github.com/stamen/modestmaps-js) and Google Maps API v3, but the system (`/lib/record.js`) is generalized beyond mapping tools of any sort, to exist as a basic Javascript AST interpreter.
Currently records support several control techniques:
@@ -93,29 +101,35 @@ Wax includes two libraries in `/lib` which are included in builds
## Changelog
+#### 1.1.0
+
+* connector/mm: Added [Modest Maps](https://github.com/stamen/modestmaps-js) connector.
+* control/mm: Added `.legend()`, `.interaction()`, and `.zoomer()` controls for Modest Maps.
+* control/lib: Added `addedTooltip` event to `tooltip.js` to allow for external styling code.
+
#### 1.0.4
* connector/g: Hide error tiles and wrap on dateline.
* connector/g: Performance improvements.
-* control/legend: Fix rerender bug
+* control/legend: Fix rerender bug.
* control/tooltip: `addedtooltip` event for binding/extending tooltip behavior. Subject to change.
#### 1.0.3
-* Embedder functionality for Google Maps and OpenLayers
+* Embedder functionality for Google Maps and OpenLayers.
#### 1.0.2
-* Bug fixes for Firefox 3
+* Bug fixes for Firefox 3.
#### 1.0.1
* `make ext` added for downloading and installing external libraries needed to use examples.
-* Bug fixes for legend, IE compatibility
+* Bug fixes for legend, IE compatibility.
#### 1.0.0
-* Initial release
+* Initial release.
## Authors
View
@@ -1186,6 +1186,29 @@ wax.Record = function(obj, context) {
// Wax header
var wax = wax || {};
+// Nondrag
+// -------
+// A simple abstraction from the `mousemove` handler that doesn't
+// trigger mousemove events while dragging.
+(function($) {
+ $.fn.extend({
+ nondrag: function(callback) {
+ $(this).bind('mousedown mouseup mousemove', function(evt) {
+ var down = false;
+ if (evt.type === 'mouseup') {
+ down = false;
+ } else if (down || evt.type === 'mousedown') {
+ down = true;
+ // Don't trigger the callback if this is a drag.
+ return;
+ }
+ callback(evt);
+ });
+ return this;
+ }
+ });
+})(jQuery);
+
// Request
// -------
// Request data cache. `callback(data)` where `data` is the response data.
@@ -1228,21 +1251,21 @@ wax.request = {
});
}
}
-}
+};
// GridInstance
// ------------
// GridInstances are queryable, fully-formed
// objects for acquiring features from events.
-wax.GridInstance = function (grid_tile, formatter) {
+wax.GridInstance = function(grid_tile, formatter) {
this.grid_tile = grid_tile;
this.formatter = formatter;
this.tileRes = 4;
-}
+};
// Resolve the UTF-8 encoding stored in grids to simple
// number values.
-// See the [utfgrid section of the mbtiles spec](https://github.com/mapbox/mbtiles-spec/blob/master/1.1/utfgrid.md)
+// See the [utfgrid section of the mbtiles spec](https://github.com/mapbox/mbtiles-spec/blob/master/1.1/utfgrid.md)
// for details.
wax.GridInstance.prototype.resolveCode = function(key) {
(key >= 93) && key--;
@@ -1285,12 +1308,12 @@ wax.GridInstance.prototype.getFeature = function(x, y, tile_element, options) {
// GridManager
// -----------
// Generally one GridManager will be used per map.
-wax.GridManager = function () {
+wax.GridManager = function() {
this.grid_tiles = {};
this.key_maps = {};
this.formatters = {};
this.locks = {};
-}
+};
// Get a grid - calls `callback` with either a `GridInstance`
// object or false. Behind the scenes, this calls `getFormatter`
@@ -1360,7 +1383,7 @@ wax.Formatter = function(obj) {
} else {
this.f = function() {};
}
-}
+};
// Wrap the given formatter function in order to
// catch exceptions that it may throw.
@@ -1426,7 +1449,7 @@ wax.tooltip.getToolTip = function(feature, context, index, evt) {
tooltip = $("<div class='wax-tooltip wax-tooltip-" +
index +
"'>" +
- "</div>").html(feature);
+ '</div>').html(feature);
if (!$(context).triggerHandler('addedtooltip', [tooltip, context, evt])) {
$(context).append(tooltip);
}
@@ -1470,7 +1493,7 @@ wax.tooltip.select = function(feature, context, layer_id, evt) {
// highest layer underneath if found.
wax.tooltip.unselect = function(feature, context, layer_id, evt) {
$(context)
- .css('cursor', 'default')
+ .css('cursor', 'default');
if (layer_id) {
$('div.wax-tooltip-' + layer_id + ':not(.wax-popup)')
.remove();
@@ -1613,7 +1636,7 @@ wax.g.Controls.prototype.Embedder = function(script_id) {
'z-index': '9999999999',
'position': 'relative'
})
- .val("<div id='" + script_id + "'>" + $('#' + script_id).html() + "</div>"));
+ .val("<div id='" + script_id + "'>" + $('#' + script_id).html() + '</div>'));
return this;
};
// Wax for Google Maps API v3
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -1186,6 +1186,29 @@ wax.Record = function(obj, context) {
// Wax header
var wax = wax || {};
+// Nondrag
+// -------
+// A simple abstraction from the `mousemove` handler that doesn't
+// trigger mousemove events while dragging.
+(function($) {
+ $.fn.extend({
+ nondrag: function(callback) {
+ $(this).bind('mousedown mouseup mousemove', function(evt) {
+ var down = false;
+ if (evt.type === 'mouseup') {
+ down = false;
+ } else if (down || evt.type === 'mousedown') {
+ down = true;
+ // Don't trigger the callback if this is a drag.
+ return;
+ }
+ callback(evt);
+ });
+ return this;
+ }
+ });
+})(jQuery);
+
// Request
// -------
// Request data cache. `callback(data)` where `data` is the response data.
@@ -1228,21 +1251,21 @@ wax.request = {
});
}
}
-}
+};
// GridInstance
// ------------
// GridInstances are queryable, fully-formed
// objects for acquiring features from events.
-wax.GridInstance = function (grid_tile, formatter) {
+wax.GridInstance = function(grid_tile, formatter) {
this.grid_tile = grid_tile;
this.formatter = formatter;
this.tileRes = 4;
-}
+};
// Resolve the UTF-8 encoding stored in grids to simple
// number values.
-// See the [utfgrid section of the mbtiles spec](https://github.com/mapbox/mbtiles-spec/blob/master/1.1/utfgrid.md)
+// See the [utfgrid section of the mbtiles spec](https://github.com/mapbox/mbtiles-spec/blob/master/1.1/utfgrid.md)
// for details.
wax.GridInstance.prototype.resolveCode = function(key) {
(key >= 93) && key--;
@@ -1285,12 +1308,12 @@ wax.GridInstance.prototype.getFeature = function(x, y, tile_element, options) {
// GridManager
// -----------
// Generally one GridManager will be used per map.
-wax.GridManager = function () {
+wax.GridManager = function() {
this.grid_tiles = {};
this.key_maps = {};
this.formatters = {};
this.locks = {};
-}
+};
// Get a grid - calls `callback` with either a `GridInstance`
// object or false. Behind the scenes, this calls `getFormatter`
@@ -1360,7 +1383,7 @@ wax.Formatter = function(obj) {
} else {
this.f = function() {};
}
-}
+};
// Wrap the given formatter function in order to
// catch exceptions that it may throw.
@@ -1426,7 +1449,7 @@ wax.tooltip.getToolTip = function(feature, context, index, evt) {
tooltip = $("<div class='wax-tooltip wax-tooltip-" +
index +
"'>" +
- "</div>").html(feature);
+ '</div>').html(feature);
if (!$(context).triggerHandler('addedtooltip', [tooltip, context, evt])) {
$(context).append(tooltip);
}
@@ -1470,7 +1493,7 @@ wax.tooltip.select = function(feature, context, layer_id, evt) {
// highest layer underneath if found.
wax.tooltip.unselect = function(feature, context, layer_id, evt) {
$(context)
- .css('cursor', 'default')
+ .css('cursor', 'default');
if (layer_id) {
$('div.wax-tooltip-' + layer_id + ':not(.wax-popup)')
.remove();
@@ -1486,6 +1509,29 @@ wax.tooltip.unselect = function(feature, context, layer_id, evt) {
.removeClass('hidden')
.show();
};
+// Wax: Fullscreen
+// -----------------
+
+// namespacing!
+if (!com) {
+ var com = { };
+ if (!com.modestmaps) {
+ com.modestmaps = { };
+ }
+}
+
+// Add zoom links, which can be styled as buttons, to a `modestmaps.Map`
+// control. This function can be used chaining-style with other
+// chaining-style controls.
+com.modestmaps.Map.prototype.fullscreen = function() {
+ $('<a class="fullscreen" href="#fullscreen">fullscreen</a>')
+ .click($.proxy(function() {
+ this.parent.toggleClass('fullscreen');
+ return false;
+ }, this))
+ .prependTo(this.parent);
+ return this;
+};
// namespacing!
if (!com) {
var com = { };
@@ -1525,16 +1571,7 @@ com.modestmaps.Map.prototype.interaction = function(options) {
})(this.tiles));
};
- // TODO: don't track on drag
- $(this.parent).bind('mousedown mouseup mousemove', $.proxy(function(evt) {
- var down = false;
- if (evt.type === 'mouseup') {
- down = false;
- } else if (down || evt.type === 'mousedown') {
- down = true;
- return;
- }
-
+ $(this.parent).nondrag($.proxy(function(evt) {
var grid = this.waxGetTileGrid();
for (var i = 0; i < grid.length; i++) {
if ((grid[i][0] < evt.pageY) &&
@@ -1584,7 +1621,7 @@ com.modestmaps.Map.prototype.interaction = function(options) {
// Wax: Legend Control
// -------------------
// Requires:
-//
+//
// * modestmaps
// * wax.Legend
View

Large diffs are not rendered by default.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 046add4

Please sign in to comment.