Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Reorganised demos and dependencies, added minified js.

 - moved "unsupported" code into example folder
 - moved core modestmaps.js into root
 - moved lib dependencies into demo folders
 - added yuicompressor, Makefile and minified version.



git-svn-id: https://modestmaps.googlecode.com/svn/trunk/js@860 a23cadb0-8de1-11de-82e5-a1837a67dc72
  • Loading branch information...
commit c1a9828ebbdbb9ece4739da8ca50caa5ae5e14fb 1 parent 6d52708
tom.carden authored
Showing with 1,082 additions and 30 deletions.
  1. +5 −0 Makefile
  2. +9 −0 README
  3. +14 −0 examples/README
  4. 0  { → examples}/broken/index-webkit.html
  5. 0  { → examples}/broken/modestmaps-webkit.js
  6. +1 −0  examples/bubble/README
  7. +3 −3 examples/{ → bubble}/canvas-bubble.html
  8. 0  {lib → examples/bubble}/excanvas.js
  9. 0  {src/overlays → examples/bubble}/follower-canvas.js
  10. +1 −1  examples/cabs/cabspotting.html
  11. +2 −2 examples/{ → cloudmade}/cloudmade.html
  12. 0  {src/mapproviders → examples/cloudmade}/cloudmade.js
  13. +8 −0 examples/flickr/bluemarble.js
  14. +3 −2 examples/{ → flickr}/flickr.html
  15. 0  {src/overlays → examples/flickr}/follower.js
  16. +5 −5 examples/hurricanes/hurricanes-raph.html
  17. +6 −6 examples/hurricanes/hurricanes.html
  18. 0  { → examples/hurricanes}/lib/dojo.xd.js
  19. +795 −0 examples/hurricanes/lib/excanvas.js
  20. 0  { → examples/hurricanes}/lib/jquery.min.js
  21. 0  { → examples/hurricanes}/lib/raphael.js
  22. 0  {src/extras → examples/hurricanes}/mapcontrols-dojo.js
  23. 0  {src/extras → examples/hurricanes}/mapcontrols-raphael.js
  24. 0  {src/overlays → examples/hurricanes}/polygonmarker-canvas.js
  25. 0  {src/overlays → examples/hurricanes}/polygonmarker-raphael.js
  26. +87 −0 examples/simple/follower.js
  27. +2 −2 examples/{ → simple}/index.html
  28. +0 −9 {src → }/modestmaps.js
  29. +1 −0  modestmaps.min.js
  30. +140 −0 tools/README
  31. BIN  tools/yuicompressor-2.4.2.jar
View
5 Makefile
@@ -0,0 +1,5 @@
+modestmaps.min.js: modestmaps.js
+ java -jar tools/yuicompressor-2.4.2.jar modestmaps.js > modestmaps.min.js
+
+clean:
+ rm modestmaps.min.js
View
9 README
@@ -1,3 +1,12 @@
+ _ _ _
+ | | | | (_)
+ _ __ ___ ___ __| | ___ ___| |_ _ __ ___ __ _ _ __ ___ _ ___
+| '_ ` _ \ / _ \ / _` |/ _ \/ __| __| | '_ ` _ \ / _` | '_ \/ __| | / __|
+| | | | | | (_) | (_| | __/\__ \ |_ | | | | | | (_| | |_) \__ \ | \__ \
+|_| |_| |_|\___/ \__,_|\___||___/\__| |_| |_| |_|\__,_| .__/|___/ | |___/
+ | | _/ |
+ |_| |__/
+
Modest Maps JS is experimental, and under active development.
Plans involve experimentation with the following:
View
14 examples/README
@@ -0,0 +1,14 @@
+Some of Modest Maps JS is experimental, and under active development. These examples reflect this exploration, and occasionally use external libraries (like jquery, raphael, excanvas and dojo) that the core Modest Maps code does not depend on.
+
+Plans involve experimentation with the following:
+
+* SVG and Canvas drawing
+* Webkit/Gecko CSS transforms/animations
+* IE CSS filters.
+* arbitrary zoom levels
+* rotations
+* touch events
+* ipad/iphone/ipod/android support
+
+Contributions are welcome! Please speak up on getsatisfaction.com if you would like to get involved, or contact us via github or Google Code.
+
View
0  broken/index-webkit.html → examples/broken/index-webkit.html
File renamed without changes
View
0  broken/modestmaps-webkit.js → examples/broken/modestmaps-webkit.js
File renamed without changes
View
1  examples/bubble/README
@@ -0,0 +1 @@
+excanvas is from http://code.google.com/p/explorercanvas/ and licensed under Apache License 2.0
View
6 examples/canvas-bubble.html → examples/bubble/canvas-bubble.html
@@ -1,9 +1,9 @@
<html>
<head>
<title>Modest Maps JS</title>
-<!--[if IE]><script type="text/javascript" src="../lib/excanvas.js"></script><![endif]-->
-<script type="text/javascript" src="../src/modestmaps.js"></script>
-<script type="text/javascript" src="../src/overlays/follower-canvas.js"></script>
+<!--[if IE]><script type="text/javascript" src="excanvas.js"></script><![endif]-->
+<script type="text/javascript" src="../../src/modestmaps.js"></script>
+<script type="text/javascript" src="follower-canvas.js"></script>
<script type="text/javascript">
var map;
function initMap() {
View
0  lib/excanvas.js → examples/bubble/excanvas.js
File renamed without changes
View
0  src/overlays/follower-canvas.js → examples/bubble/follower-canvas.js
File renamed without changes
View
2  examples/cabs/cabspotting.html
@@ -2,7 +2,7 @@
<head>
<title>Modest Maps JS</title>
<script type="text/javascript" src="../../src/modestmaps.js"></script>
-<script type="text/javascript" src="../../src/mapproviders/cloudmade.js"></script>
+<script type="text/javascript" src="../cloudmade/cloudmade.js"></script>
<script type="text/javascript" src="cab-follower.js"></script>
<script type="text/javascript">
View
4 examples/cloudmade.html → examples/cloudmade/cloudmade.html
@@ -1,8 +1,8 @@
<html>
<head>
<title>Modest Maps JS</title>
-<script type="text/javascript" src="../src/modestmaps.js"></script>
-<script type="text/javascript" src="../src/mapproviders/cloudmade.js"></script>
+<script type="text/javascript" src="../../src/modestmaps.js"></script>
+<script type="text/javascript" src="cloudmade.js"></script>
<script type="text/javascript">
var map;
function initMap() {
View
0  src/mapproviders/cloudmade.js → examples/cloudmade/cloudmade.js
File renamed without changes
View
8 examples/flickr/bluemarble.js
@@ -0,0 +1,8 @@
+com.modestmaps.BlueMarbleProvider = function() {
+ com.modestmaps.MapProvider.call(this, function(coordinate) {
+ var img = coordinate.zoom.toFixed(0) +'-r'+ coordinate.row.toFixed(0) +'-c'+ coordinate.column.toFixed(0) + '.jpg';
+ return 'http://s3.amazonaws.com/com.modestmaps.bluemarble/' + img;
+ });
+};
+
+com.modestmaps.extend(com.modestmaps.BlueMarbleProvider, com.modestmaps.MapProvider);
View
5 examples/flickr.html → examples/flickr/flickr.html
@@ -1,8 +1,9 @@
<html>
<head>
<title>Modest Maps JS</title>
-<script type="text/javascript" src="../src/modestmaps.js"></script>
-<script type="text/javascript" src="../src/overlays/follower.js"></script>
+<script type="text/javascript" src="../../src/modestmaps.js"></script>
+<script type="text/javascript" src="bluemarble.js"></script>
+<script type="text/javascript" src="follower.js"></script>
<script type="text/javascript">
var map;
var jsonFlickrApi;
View
0  src/overlays/follower.js → examples/flickr/follower.js
File renamed without changes
View
10 examples/hurricanes/hurricanes-raph.html
@@ -1,12 +1,12 @@
<html>
<head>
<title>Modest Maps JS</title>
-<script type="text/javascript" src="../../lib/jquery.min.js"></script>
-<script type="text/javascript" src="../../lib/raphael.js"></script>
+<script type="text/javascript" src="lib/jquery.min.js"></script>
+<script type="text/javascript" src="lib/raphael.js"></script>
<script type="text/javascript" src="../../src/modestmaps.js"></script>
-<script type="text/javascript" src="../../src/mapproviders/cloudmade.js"></script>
-<script type="text/javascript" src="../../src/extras/mapcontrols-raphael.js"></script>
-<script type="text/javascript" src="../../src/overlays/polygonmarker-raphael.js"></script>
+<script type="text/javascript" src="../cloudmade/cloudmade.js"></script>
+<script type="text/javascript" src="mapcontrols-raphael.js"></script>
+<script type="text/javascript" src="polygonmarker-raphael.js"></script>
<script type="text/javascript">
var map;
View
12 examples/hurricanes/hurricanes.html
@@ -1,15 +1,15 @@
<html>
<head>
<title>Modest Maps JS</title>
-<script type="text/javascript" src="../../lib/jquery.min.js"></script>
+<script type="text/javascript" src="lib/jquery.min.js"></script>
<!--[if IE]>
-<script type="text/javascript" src="../../lib/excanvas.js"></script>
+<script type="text/javascript" src="lib/excanvas.js"></script>
<![endif]-->
-<script type="text/javascript" src="../../lib/dojo.xd.js"></script>
+<script type="text/javascript" src="lib/dojo.xd.js"></script>
<script type="text/javascript" src="../../src/modestmaps.js"></script>
-<script type="text/javascript" src="../../src/mapproviders/cloudmade.js"></script>
-<script type="text/javascript" src="../../src/extras/mapcontrols-dojo.js"></script>
-<script type="text/javascript" src="../../src/overlays/polygonmarker-canvas.js"></script>
+<script type="text/javascript" src="../cloudmade/cloudmade.js"></script>
+<script type="text/javascript" src="mapcontrols-dojo.js"></script>
+<script type="text/javascript" src="polygonmarker-canvas.js"></script>
<script type="text/javascript">
var map;
View
0  lib/dojo.xd.js → examples/hurricanes/lib/dojo.xd.js
File renamed without changes
View
795 examples/hurricanes/lib/excanvas.js
@@ -0,0 +1,795 @@
+// Copyright 2006 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+
+// Known Issues:
+//
+// * Patterns are not implemented.
+// * Radial gradient are not implemented. The VML version of these look very
+// different from the canvas one.
+// * Clipping paths are not implemented.
+// * Coordsize. The width and height attribute have higher priority than the
+// width and height style values which isn't correct.
+// * Painting mode isn't implemented.
+// * Canvas width/height should is using content-box by default. IE in
+// Quirks mode will draw the canvas using border-box. Either change your
+// doctype to HTML5
+// (http://www.whatwg.org/specs/web-apps/current-work/#the-doctype)
+// or use Box Sizing Behavior from WebFX
+// (http://webfx.eae.net/dhtml/boxsizing/boxsizing.html)
+// * Optimize. There is always room for speed improvements.
+
+// only add this code if we do not already have a canvas implementation
+if (!window.CanvasRenderingContext2D) {
+
+(function () {
+
+ // alias some functions to make (compiled) code shorter
+ var m = Math;
+ var mr = m.round;
+ var ms = m.sin;
+ var mc = m.cos;
+
+ // this is used for sub pixel precision
+ var Z = 10;
+ var Z2 = Z / 2;
+
+ var G_vmlCanvasManager_ = {
+ init: function (opt_doc) {
+ var doc = opt_doc || document;
+ if (/MSIE/.test(navigator.userAgent) && !window.opera) {
+ var self = this;
+ doc.attachEvent("onreadystatechange", function () {
+ self.init_(doc);
+ });
+ }
+ },
+
+ init_: function (doc) {
+ if (doc.readyState == "complete") {
+ // create xmlns
+ if (!doc.namespaces["g_vml_"]) {
+ doc.namespaces.add("g_vml_", "urn:schemas-microsoft-com:vml");
+ }
+
+ // setup default css
+ var ss = doc.createStyleSheet();
+ ss.cssText = "canvas{display:inline-block;overflow:hidden;" +
+ // default size is 300x150 in Gecko and Opera
+ "text-align:left;width:300px;height:150px}" +
+ "g_vml_\\:*{behavior:url(#default#VML)}";
+
+ // find all canvas elements
+ var els = doc.getElementsByTagName("canvas");
+ for (var i = 0; i < els.length; i++) {
+ if (!els[i].getContext) {
+ this.initElement(els[i]);
+ }
+ }
+ }
+ },
+
+ fixElement_: function (el) {
+ // in IE before version 5.5 we would need to add HTML: to the tag name
+ // but we do not care about IE before version 6
+ var outerHTML = el.outerHTML;
+
+ var newEl = el.ownerDocument.createElement(outerHTML);
+ // if the tag is still open IE has created the children as siblings and
+ // it has also created a tag with the name "/FOO"
+ if (outerHTML.slice(-2) != "/>") {
+ var tagName = "/" + el.tagName;
+ var ns;
+ // remove content
+ while ((ns = el.nextSibling) && ns.tagName != tagName) {
+ ns.removeNode();
+ }
+ // remove the incorrect closing tag
+ if (ns) {
+ ns.removeNode();
+ }
+ }
+ el.parentNode.replaceChild(newEl, el);
+ return newEl;
+ },
+
+ /**
+ * Public initializes a canvas element so that it can be used as canvas
+ * element from now on. This is called automatically before the page is
+ * loaded but if you are creating elements using createElement you need to
+ * make sure this is called on the element.
+ * @param {HTMLElement} el The canvas element to initialize.
+ * @return {HTMLElement} the element that was created.
+ */
+ initElement: function (el) {
+ el = this.fixElement_(el);
+ el.getContext = function () {
+ if (this.context_) {
+ return this.context_;
+ }
+ return this.context_ = new CanvasRenderingContext2D_(this);
+ };
+
+ // do not use inline function because that will leak memory
+ el.attachEvent('onpropertychange', onPropertyChange);
+ el.attachEvent('onresize', onResize);
+
+ var attrs = el.attributes;
+ if (attrs.width && attrs.width.specified) {
+ // TODO: use runtimeStyle and coordsize
+ // el.getContext().setWidth_(attrs.width.nodeValue);
+ el.style.width = attrs.width.nodeValue + "px";
+ } else {
+ el.width = el.clientWidth;
+ }
+ if (attrs.height && attrs.height.specified) {
+ // TODO: use runtimeStyle and coordsize
+ // el.getContext().setHeight_(attrs.height.nodeValue);
+ el.style.height = attrs.height.nodeValue + "px";
+ } else {
+ el.height = el.clientHeight;
+ }
+ //el.getContext().setCoordsize_()
+ return el;
+ }
+ };
+
+ function onPropertyChange(e) {
+ var el = e.srcElement;
+
+ switch (e.propertyName) {
+ case 'width':
+ el.style.width = el.attributes.width.nodeValue + "px";
+ el.getContext().clearRect();
+ break;
+ case 'height':
+ el.style.height = el.attributes.height.nodeValue + "px";
+ el.getContext().clearRect();
+ break;
+ }
+ }
+
+ function onResize(e) {
+ var el = e.srcElement;
+ if (el.firstChild) {
+ el.firstChild.style.width = el.clientWidth + 'px';
+ el.firstChild.style.height = el.clientHeight + 'px';
+ }
+ }
+
+ G_vmlCanvasManager_.init();
+
+ // precompute "00" to "FF"
+ var dec2hex = [];
+ for (var i = 0; i < 16; i++) {
+ for (var j = 0; j < 16; j++) {
+ dec2hex[i * 16 + j] = i.toString(16) + j.toString(16);
+ }
+ }
+
+ function createMatrixIdentity() {
+ return [
+ [1, 0, 0],
+ [0, 1, 0],
+ [0, 0, 1]
+ ];
+ }
+
+ function matrixMultiply(m1, m2) {
+ var result = createMatrixIdentity();
+
+ for (var x = 0; x < 3; x++) {
+ for (var y = 0; y < 3; y++) {
+ var sum = 0;
+
+ for (var z = 0; z < 3; z++) {
+ sum += m1[x][z] * m2[z][y];
+ }
+
+ result[x][y] = sum;
+ }
+ }
+ return result;
+ }
+
+ function copyState(o1, o2) {
+ o2.fillStyle = o1.fillStyle;
+ o2.lineCap = o1.lineCap;
+ o2.lineJoin = o1.lineJoin;
+ o2.lineWidth = o1.lineWidth;
+ o2.miterLimit = o1.miterLimit;
+ o2.shadowBlur = o1.shadowBlur;
+ o2.shadowColor = o1.shadowColor;
+ o2.shadowOffsetX = o1.shadowOffsetX;
+ o2.shadowOffsetY = o1.shadowOffsetY;
+ o2.strokeStyle = o1.strokeStyle;
+ o2.arcScaleX_ = o1.arcScaleX_;
+ o2.arcScaleY_ = o1.arcScaleY_;
+ }
+
+ function processStyle(styleString) {
+ var str, alpha = 1;
+
+ styleString = String(styleString);
+ if (styleString.substring(0, 3) == "rgb") {
+ var start = styleString.indexOf("(", 3);
+ var end = styleString.indexOf(")", start + 1);
+ var guts = styleString.substring(start + 1, end).split(",");
+
+ str = "#";
+ for (var i = 0; i < 3; i++) {
+ str += dec2hex[Number(guts[i])];
+ }
+
+ if ((guts.length == 4) && (styleString.substr(3, 1) == "a")) {
+ alpha = guts[3];
+ }
+ } else {
+ str = styleString;
+ }
+
+ return [str, alpha];
+ }
+
+ function processLineCap(lineCap) {
+ switch (lineCap) {
+ case "butt":
+ return "flat";
+ case "round":
+ return "round";
+ case "square":
+ default:
+ return "square";
+ }
+ }
+
+ /**
+ * This class implements CanvasRenderingContext2D interface as described by
+ * the WHATWG.
+ * @param {HTMLElement} surfaceElement The element that the 2D context should
+ * be associated with
+ */
+ function CanvasRenderingContext2D_(surfaceElement) {
+ this.m_ = createMatrixIdentity();
+
+ this.mStack_ = [];
+ this.aStack_ = [];
+ this.currentPath_ = [];
+
+ // Canvas context properties
+ this.strokeStyle = "#000";
+ this.fillStyle = "#000";
+
+ this.lineWidth = 1;
+ this.lineJoin = "miter";
+ this.lineCap = "butt";
+ this.miterLimit = Z * 1;
+ this.globalAlpha = 1;
+ this.canvas = surfaceElement;
+
+ var el = surfaceElement.ownerDocument.createElement('div');
+ el.style.width = surfaceElement.clientWidth + 'px';
+ el.style.height = surfaceElement.clientHeight + 'px';
+ el.style.overflow = 'hidden';
+ el.style.position = 'absolute';
+ surfaceElement.appendChild(el);
+
+ this.element_ = el;
+ this.arcScaleX_ = 1;
+ this.arcScaleY_ = 1;
+ };
+
+ var contextPrototype = CanvasRenderingContext2D_.prototype;
+ contextPrototype.clearRect = function() {
+ this.element_.innerHTML = "";
+ this.currentPath_ = [];
+ };
+
+ contextPrototype.beginPath = function() {
+ // TODO: Branch current matrix so that save/restore has no effect
+ // as per safari docs.
+
+ this.currentPath_ = [];
+ };
+
+ contextPrototype.moveTo = function(aX, aY) {
+ this.currentPath_.push({type: "moveTo", x: aX, y: aY});
+ this.currentX_ = aX;
+ this.currentY_ = aY;
+ };
+
+ contextPrototype.lineTo = function(aX, aY) {
+ this.currentPath_.push({type: "lineTo", x: aX, y: aY});
+ this.currentX_ = aX;
+ this.currentY_ = aY;
+ };
+
+ contextPrototype.bezierCurveTo = function(aCP1x, aCP1y,
+ aCP2x, aCP2y,
+ aX, aY) {
+ this.currentPath_.push({type: "bezierCurveTo",
+ cp1x: aCP1x,
+ cp1y: aCP1y,
+ cp2x: aCP2x,
+ cp2y: aCP2y,
+ x: aX,
+ y: aY});
+ this.currentX_ = aX;
+ this.currentY_ = aY;
+ };
+
+ contextPrototype.quadraticCurveTo = function(aCPx, aCPy, aX, aY) {
+ // the following is lifted almost directly from
+ // http://developer.mozilla.org/en/docs/Canvas_tutorial:Drawing_shapes
+ var cp1x = this.currentX_ + 2.0 / 3.0 * (aCPx - this.currentX_);
+ var cp1y = this.currentY_ + 2.0 / 3.0 * (aCPy - this.currentY_);
+ var cp2x = cp1x + (aX - this.currentX_) / 3.0;
+ var cp2y = cp1y + (aY - this.currentY_) / 3.0;
+ this.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, aX, aY);
+ };
+
+ contextPrototype.arc = function(aX, aY, aRadius,
+ aStartAngle, aEndAngle, aClockwise) {
+ aRadius *= Z;
+ var arcType = aClockwise ? "at" : "wa";
+
+ var xStart = aX + (mc(aStartAngle) * aRadius) - Z2;
+ var yStart = aY + (ms(aStartAngle) * aRadius) - Z2;
+
+ var xEnd = aX + (mc(aEndAngle) * aRadius) - Z2;
+ var yEnd = aY + (ms(aEndAngle) * aRadius) - Z2;
+
+ // IE won't render arches drawn counter clockwise if xStart == xEnd.
+ if (xStart == xEnd && !aClockwise) {
+ xStart += 0.125; // Offset xStart by 1/80 of a pixel. Use something
+ // that can be represented in binary
+ }
+
+ this.currentPath_.push({type: arcType,
+ x: aX,
+ y: aY,
+ radius: aRadius,
+ xStart: xStart,
+ yStart: yStart,
+ xEnd: xEnd,
+ yEnd: yEnd});
+
+ };
+
+ contextPrototype.rect = function(aX, aY, aWidth, aHeight) {
+ this.moveTo(aX, aY);
+ this.lineTo(aX + aWidth, aY);
+ this.lineTo(aX + aWidth, aY + aHeight);
+ this.lineTo(aX, aY + aHeight);
+ this.closePath();
+ };
+
+ contextPrototype.strokeRect = function(aX, aY, aWidth, aHeight) {
+ // Will destroy any existing path (same as FF behaviour)
+ this.beginPath();
+ this.moveTo(aX, aY);
+ this.lineTo(aX + aWidth, aY);
+ this.lineTo(aX + aWidth, aY + aHeight);
+ this.lineTo(aX, aY + aHeight);
+ this.closePath();
+ this.stroke();
+ };
+
+ contextPrototype.fillRect = function(aX, aY, aWidth, aHeight) {
+ // Will destroy any existing path (same as FF behaviour)
+ this.beginPath();
+ this.moveTo(aX, aY);
+ this.lineTo(aX + aWidth, aY);
+ this.lineTo(aX + aWidth, aY + aHeight);
+ this.lineTo(aX, aY + aHeight);
+ this.closePath();
+ this.fill();
+ };
+
+ contextPrototype.createLinearGradient = function(aX0, aY0, aX1, aY1) {
+ var gradient = new CanvasGradient_("gradient");
+ return gradient;
+ };
+
+ contextPrototype.createRadialGradient = function(aX0, aY0,
+ aR0, aX1,
+ aY1, aR1) {
+ var gradient = new CanvasGradient_("gradientradial");
+ gradient.radius1_ = aR0;
+ gradient.radius2_ = aR1;
+ gradient.focus_.x = aX0;
+ gradient.focus_.y = aY0;
+ return gradient;
+ };
+
+ contextPrototype.drawImage = function (image, var_args) {
+ var dx, dy, dw, dh, sx, sy, sw, sh;
+
+ // to find the original width we overide the width and height
+ var oldRuntimeWidth = image.runtimeStyle.width;
+ var oldRuntimeHeight = image.runtimeStyle.height;
+ image.runtimeStyle.width = 'auto';
+ image.runtimeStyle.height = 'auto';
+
+ // get the original size
+ var w = image.width;
+ var h = image.height;
+
+ // and remove overides
+ image.runtimeStyle.width = oldRuntimeWidth;
+ image.runtimeStyle.height = oldRuntimeHeight;
+
+ if (arguments.length == 3) {
+ dx = arguments[1];
+ dy = arguments[2];
+ sx = sy = 0;
+ sw = dw = w;
+ sh = dh = h;
+ } else if (arguments.length == 5) {
+ dx = arguments[1];
+ dy = arguments[2];
+ dw = arguments[3];
+ dh = arguments[4];
+ sx = sy = 0;
+ sw = w;
+ sh = h;
+ } else if (arguments.length == 9) {
+ sx = arguments[1];
+ sy = arguments[2];
+ sw = arguments[3];
+ sh = arguments[4];
+ dx = arguments[5];
+ dy = arguments[6];
+ dw = arguments[7];
+ dh = arguments[8];
+ } else {
+ throw "Invalid number of arguments";
+ }
+
+ var d = this.getCoords_(dx, dy);
+
+ var w2 = sw / 2;
+ var h2 = sh / 2;
+
+ var vmlStr = [];
+
+ var W = 10;
+ var H = 10;
+
+ // For some reason that I've now forgotten, using divs didn't work
+ vmlStr.push(' <g_vml_:group',
+ ' coordsize="', Z * W, ',', Z * H, '"',
+ ' coordorigin="0,0"' ,
+ ' style="width:', W, ';height:', H, ';position:absolute;');
+
+ // If filters are necessary (rotation exists), create them
+ // filters are bog-slow, so only create them if abbsolutely necessary
+ // The following check doesn't account for skews (which don't exist
+ // in the canvas spec (yet) anyway.
+
+ if (this.m_[0][0] != 1 || this.m_[0][1]) {
+ var filter = [];
+
+ // Note the 12/21 reversal
+ filter.push("M11='", this.m_[0][0], "',",
+ "M12='", this.m_[1][0], "',",
+ "M21='", this.m_[0][1], "',",
+ "M22='", this.m_[1][1], "',",
+ "Dx='", mr(d.x / Z), "',",
+ "Dy='", mr(d.y / Z), "'");
+
+ // Bounding box calculation (need to minimize displayed area so that
+ // filters don't waste time on unused pixels.
+ var max = d;
+ var c2 = this.getCoords_(dx + dw, dy);
+ var c3 = this.getCoords_(dx, dy + dh);
+ var c4 = this.getCoords_(dx + dw, dy + dh);
+
+ max.x = Math.max(max.x, c2.x, c3.x, c4.x);
+ max.y = Math.max(max.y, c2.y, c3.y, c4.y);
+
+ vmlStr.push("padding:0 ", mr(max.x / Z), "px ", mr(max.y / Z),
+ "px 0;filter:progid:DXImageTransform.Microsoft.Matrix(",
+ filter.join(""), ", sizingmethod='clip');")
+ } else {
+ vmlStr.push("top:", mr(d.y / Z), "px;left:", mr(d.x / Z), "px;")
+ }
+
+ vmlStr.push(' ">' ,
+ '<g_vml_:image src="', image.src, '"',
+ ' style="width:', Z * dw, ';',
+ ' height:', Z * dh, ';"',
+ ' cropleft="', sx / w, '"',
+ ' croptop="', sy / h, '"',
+ ' cropright="', (w - sx - sw) / w, '"',
+ ' cropbottom="', (h - sy - sh) / h, '"',
+ ' />',
+ '</g_vml_:group>');
+
+ this.element_.insertAdjacentHTML("BeforeEnd",
+ vmlStr.join(""));
+ };
+
+ contextPrototype.stroke = function(aFill) {
+ var lineStr = [];
+ var lineOpen = false;
+ var a = processStyle(aFill ? this.fillStyle : this.strokeStyle);
+ var color = a[0];
+ var opacity = a[1] * this.globalAlpha;
+
+ var W = 10;
+ var H = 10;
+
+ lineStr.push('<g_vml_:shape',
+ ' fillcolor="', color, '"',
+ ' filled="', Boolean(aFill), '"',
+ ' style="position:absolute;width:', W, ';height:', H, ';"',
+ ' coordorigin="0 0" coordsize="', Z * W, ' ', Z * H, '"',
+ ' stroked="', !aFill, '"',
+ ' strokeweight="', this.lineWidth, '"',
+ ' strokecolor="', color, '"',
+ ' path="');
+
+ var newSeq = false;
+ var min = {x: null, y: null};
+ var max = {x: null, y: null};
+
+ for (var i = 0; i < this.currentPath_.length; i++) {
+ var p = this.currentPath_[i];
+
+ if (p.type == "moveTo") {
+ lineStr.push(" m ");
+ var c = this.getCoords_(p.x, p.y);
+ lineStr.push(mr(c.x), ",", mr(c.y));
+ } else if (p.type == "lineTo") {
+ lineStr.push(" l ");
+ var c = this.getCoords_(p.x, p.y);
+ lineStr.push(mr(c.x), ",", mr(c.y));
+ } else if (p.type == "close") {
+ lineStr.push(" x ");
+ } else if (p.type == "bezierCurveTo") {
+ lineStr.push(" c ");
+ var c = this.getCoords_(p.x, p.y);
+ var c1 = this.getCoords_(p.cp1x, p.cp1y);
+ var c2 = this.getCoords_(p.cp2x, p.cp2y);
+ lineStr.push(mr(c1.x), ",", mr(c1.y), ",",
+ mr(c2.x), ",", mr(c2.y), ",",
+ mr(c.x), ",", mr(c.y));
+ } else if (p.type == "at" || p.type == "wa") {
+ lineStr.push(" ", p.type, " ");
+ var c = this.getCoords_(p.x, p.y);
+ var cStart = this.getCoords_(p.xStart, p.yStart);
+ var cEnd = this.getCoords_(p.xEnd, p.yEnd);
+
+ lineStr.push(mr(c.x - this.arcScaleX_ * p.radius), ",",
+ mr(c.y - this.arcScaleY_ * p.radius), " ",
+ mr(c.x + this.arcScaleX_ * p.radius), ",",
+ mr(c.y + this.arcScaleY_ * p.radius), " ",
+ mr(cStart.x), ",", mr(cStart.y), " ",
+ mr(cEnd.x), ",", mr(cEnd.y));
+ }
+
+
+ // TODO: Following is broken for curves due to
+ // move to proper paths.
+
+ // Figure out dimensions so we can do gradient fills
+ // properly
+ if(c) {
+ if (min.x == null || c.x < min.x) {
+ min.x = c.x;
+ }
+ if (max.x == null || c.x > max.x) {
+ max.x = c.x;
+ }
+ if (min.y == null || c.y < min.y) {
+ min.y = c.y;
+ }
+ if (max.y == null || c.y > max.y) {
+ max.y = c.y;
+ }
+ }
+ }
+ lineStr.push(' ">');
+
+ if (typeof this.fillStyle == "object") {
+ var focus = {x: "50%", y: "50%"};
+ var width = (max.x - min.x);
+ var height = (max.y - min.y);
+ var dimension = (width > height) ? width : height;
+
+ focus.x = mr((this.fillStyle.focus_.x / width) * 100 + 50) + "%";
+ focus.y = mr((this.fillStyle.focus_.y / height) * 100 + 50) + "%";
+
+ var colors = [];
+
+ // inside radius (%)
+ if (this.fillStyle.type_ == "gradientradial") {
+ var inside = (this.fillStyle.radius1_ / dimension * 100);
+
+ // percentage that outside radius exceeds inside radius
+ var expansion = (this.fillStyle.radius2_ / dimension * 100) - inside;
+ } else {
+ var inside = 0;
+ var expansion = 100;
+ }
+
+ var insidecolor = {offset: null, color: null};
+ var outsidecolor = {offset: null, color: null};
+
+ // We need to sort 'colors' by percentage, from 0 > 100 otherwise ie
+ // won't interpret it correctly
+ this.fillStyle.colors_.sort(function (cs1, cs2) {
+ return cs1.offset - cs2.offset;
+ });
+
+ for (var i = 0; i < this.fillStyle.colors_.length; i++) {
+ var fs = this.fillStyle.colors_[i];
+
+ colors.push( (fs.offset * expansion) + inside, "% ", fs.color, ",");
+
+ if (fs.offset > insidecolor.offset || insidecolor.offset == null) {
+ insidecolor.offset = fs.offset;
+ insidecolor.color = fs.color;
+ }
+
+ if (fs.offset < outsidecolor.offset || outsidecolor.offset == null) {
+ outsidecolor.offset = fs.offset;
+ outsidecolor.color = fs.color;
+ }
+ }
+ colors.pop();
+
+ lineStr.push('<g_vml_:fill',
+ ' color="', outsidecolor.color, '"',
+ ' color2="', insidecolor.color, '"',
+ ' type="', this.fillStyle.type_, '"',
+ ' focusposition="', focus.x, ', ', focus.y, '"',
+ ' colors="', colors.join(""), '"',
+ ' opacity="', opacity, '" />');
+ } else if (aFill) {
+ lineStr.push('<g_vml_:fill color="', color, '" opacity="', opacity, '" />');
+ } else {
+ lineStr.push(
+ '<g_vml_:stroke',
+ ' opacity="', opacity,'"',
+ ' joinstyle="', this.lineJoin, '"',
+ ' miterlimit="', this.miterLimit, '"',
+ ' endcap="', processLineCap(this.lineCap) ,'"',
+ ' weight="', this.lineWidth, 'px"',
+ ' color="', color,'" />'
+ );
+ }
+
+ lineStr.push("</g_vml_:shape>");
+
+ this.element_.insertAdjacentHTML("beforeEnd", lineStr.join(""));
+
+ this.currentPath_ = [];
+ };
+
+ contextPrototype.fill = function() {
+ this.stroke(true);
+ }
+
+ contextPrototype.closePath = function() {
+ this.currentPath_.push({type: "close"});
+ };
+
+ /**
+ * @private
+ */
+ contextPrototype.getCoords_ = function(aX, aY) {
+ return {
+ x: Z * (aX * this.m_[0][0] + aY * this.m_[1][0] + this.m_[2][0]) - Z2,
+ y: Z * (aX * this.m_[0][1] + aY * this.m_[1][1] + this.m_[2][1]) - Z2
+ }
+ };
+
+ contextPrototype.save = function() {
+ var o = {};
+ copyState(this, o);
+ this.aStack_.push(o);
+ this.mStack_.push(this.m_);
+ this.m_ = matrixMultiply(createMatrixIdentity(), this.m_);
+ };
+
+ contextPrototype.restore = function() {
+ copyState(this.aStack_.pop(), this);
+ this.m_ = this.mStack_.pop();
+ };
+
+ contextPrototype.translate = function(aX, aY) {
+ var m1 = [
+ [1, 0, 0],
+ [0, 1, 0],
+ [aX, aY, 1]
+ ];
+
+ this.m_ = matrixMultiply(m1, this.m_);
+ };
+
+ contextPrototype.transform = function(m11, m12, m21, m22, dx, dy) {
+ var m1 = [
+ [m11, m12, 0],
+ [m21, m22, 0],
+ [ dx, dy, 1]
+ ];
+
+ this.m_ = matrixMultiply(m1, this.m_);
+ };
+
+ contextPrototype.rotate = function(aRot) {
+ var c = mc(aRot);
+ var s = ms(aRot);
+
+ var m1 = [
+ [c, s, 0],
+ [-s, c, 0],
+ [0, 0, 1]
+ ];
+
+ this.m_ = matrixMultiply(m1, this.m_);
+ };
+
+ contextPrototype.scale = function(aX, aY) {
+ this.arcScaleX_ *= aX;
+ this.arcScaleY_ *= aY;
+ var m1 = [
+ [aX, 0, 0],
+ [0, aY, 0],
+ [0, 0, 1]
+ ];
+
+ this.m_ = matrixMultiply(m1, this.m_);
+ };
+
+ /******** STUBS ********/
+ contextPrototype.clip = function() {
+ // TODO: Implement
+ };
+
+ contextPrototype.arcTo = function() {
+ // TODO: Implement
+ };
+
+ contextPrototype.createPattern = function() {
+ return new CanvasPattern_;
+ };
+
+ // Gradient / Pattern Stubs
+ function CanvasGradient_(aType) {
+ this.type_ = aType;
+ this.radius1_ = 0;
+ this.radius2_ = 0;
+ this.colors_ = [];
+ this.focus_ = {x: 0, y: 0};
+ }
+
+ CanvasGradient_.prototype.addColorStop = function(aOffset, aColor) {
+ aColor = processStyle(aColor);
+ this.colors_.push({offset: 1-aOffset, color: aColor});
+ };
+
+ function CanvasPattern_() {}
+
+ // set up externs
+ G_vmlCanvasManager = G_vmlCanvasManager_;
+ CanvasRenderingContext2D = CanvasRenderingContext2D_;
+ CanvasGradient = CanvasGradient_;
+ CanvasPattern = CanvasPattern_;
+
+})();
+
+} // if
View
0  lib/jquery.min.js → examples/hurricanes/lib/jquery.min.js
File renamed without changes
View
0  lib/raphael.js → examples/hurricanes/lib/raphael.js
File renamed without changes
View
0  src/extras/mapcontrols-dojo.js → examples/hurricanes/mapcontrols-dojo.js
File renamed without changes
View
0  src/extras/mapcontrols-raphael.js → examples/hurricanes/mapcontrols-raphael.js
File renamed without changes
View
0  src/overlays/polygonmarker-canvas.js → examples/hurricanes/polygonmarker-canvas.js
File renamed without changes
View
0  src/overlays/polygonmarker-raphael.js → examples/hurricanes/polygonmarker-raphael.js
File renamed without changes
View
87 examples/simple/follower.js
@@ -0,0 +1,87 @@
+// namespacing!
+if (!com) {
+ var com = { };
+ if (!com.modestmaps) {
+ com.modestmaps = { };
+ }
+}
+
+com.modestmaps.Follower = function(map, location, content, dimensions)
+{
+ this.coord = map.provider.locationCoordinate(location);
+
+ this.offset = new com.modestmaps.Point(0, 0);
+ this.dimensions = dimensions || new com.modestmaps.Point(100, 50);
+ this.padding = new com.modestmaps.Point(10, 10);
+ this.offset = new com.modestmaps.Point(0, -this.dimensions.y);
+
+ var follower = this;
+
+ var callback = function(m, a) { return follower.draw(m); };
+ map.addCallback('panned', callback);
+ map.addCallback('zoomed', callback);
+ map.addCallback('centered', callback);
+ map.addCallback('extentset', callback);
+
+ this.div = document.createElement('div');
+ this.div.style.position = 'absolute';
+ this.div.style.width = this.dimensions.x + 'px';
+ this.div.style.height = this.dimensions.y + 'px';
+ //this.div.style.backgroundColor = 'white';
+ //this.div.style.border = 'solid black 1px';
+
+ this.div.innerHTML = content;
+
+ com.modestmaps.addEvent(this.div, 'mousedown', function(e) {
+ if(!e) e = window.event;
+ return com.modestmaps.cancelEvent(e);
+ });
+
+ map.parent.appendChild(this.div);
+
+ this.draw(map);
+}
+
+com.modestmaps.Follower.prototype = {
+
+ div: null,
+ coord: null,
+
+ offset: null,
+ dimensions: null,
+ padding: null,
+
+ draw: function(map)
+ {
+ try {
+ var point = map.coordinatePoint(this.coord);
+
+ } catch(e) {
+ // too soon?
+ return;
+ }
+
+ if(point.x + this.dimensions.x + this.offset.x < 0) {
+ // too far left
+ this.div.style.display = 'none';
+
+ } else if(point.y + this.dimensions.y + this.offset.y < 0) {
+ // too far up
+ this.div.style.display = 'none';
+
+ } else if(point.x + this.offset.x > map.dimensions.x) {
+ // too far right
+ this.div.style.display = 'none';
+
+ } else if(point.y + this.offset.y > map.dimensions.y) {
+ // too far down
+ this.div.style.display = 'none';
+
+ } else {
+ this.div.style.display = 'block';
+ this.div.style.left = point.x + this.offset.x + 'px';
+ this.div.style.top = point.y + this.offset.y + 'px';
+ }
+ }
+
+};
View
4 examples/index.html → examples/simple/index.html
@@ -1,8 +1,8 @@
<html>
<head>
<title>Modest Maps JS</title>
-<script type="text/javascript" src="../src/modestmaps.js"></script>
-<script type="text/javascript" src="../src/overlays/follower.js"></script>
+<script type="text/javascript" src="../../src/modestmaps.js"></script>
+<script type="text/javascript" src="follower.js"></script>
<script type="text/javascript">
var map;
function initMap() {
View
9 src/modestmaps.js → modestmaps.js
@@ -355,15 +355,6 @@ com.modestmaps.MapProvider.prototype = {
}
};
-com.modestmaps.BlueMarbleProvider = function() {
- com.modestmaps.MapProvider.call(this, function(coordinate) {
- var img = coordinate.zoom.toFixed(0) +'-r'+ coordinate.row.toFixed(0) +'-c'+ coordinate.column.toFixed(0) + '.jpg';
- return 'http://s3.amazonaws.com/com.modestmaps.bluemarble/' + img;
- });
-};
-
-com.modestmaps.extend(com.modestmaps.BlueMarbleProvider, com.modestmaps.MapProvider);
-
//////////////////////////// Map
com.modestmaps.Map = function(parent, provider, dimensions) {
View
1  modestmaps.min.js
@@ -0,0 +1 @@
+if(!com){var com={};if(!com.modestmaps){com.modestmaps={}}}com.modestmaps.extend=function(c,a){for(var b in a.prototype){if(typeof c.prototype[b]=="undefined"){c.prototype[b]=a.prototype[b]}}return c};com.modestmaps.cancelEvent=function(a){a.cancelBubble=true;a.cancel=true;a.returnValue=false;if(a.stopPropagation){a.stopPropagation()}if(a.preventDefault){a.preventDefault()}return false};com.modestmaps.addEvent=function(c,b,a){if(c.attachEvent){c["e"+b+a]=a;c[b+a]=function(){c["e"+b+a](window.event)};c.attachEvent("on"+b,c[b+a])}else{c.addEventListener(b,a,false);if(b=="mousewheel"){c.addEventListener("DOMMouseScroll",a,false)}}};com.modestmaps.removeEvent=function(c,b,a){if(c.detachEvent){c.detachEvent("on"+b,c[b+a]);c[b+a]=null}else{c.removeEventListener(b,a,false);if(b=="mousewheel"){c.removeEventListener("DOMMouseScroll",a,false)}}};com.modestmaps.Point=function(a,b){this.x=parseFloat(a);this.y=parseFloat(b)};com.modestmaps.Point.prototype={x:0,y:0,toString:function(){return"("+this.x.toFixed(3)+", "+this.y.toFixed(3)+")"}};com.modestmaps.Coordinate=function(c,a,b){this.row=c;this.column=a;this.zoom=b};com.modestmaps.Coordinate.prototype={row:0,column:0,zoom:0,toString:function(){return"("+this.row.toFixed(3)+", "+this.column.toFixed(3)+" @"+this.zoom.toFixed(3)+")"},toKey:function(){var e=parseInt(this.row);var d=parseInt(this.column);var f=parseInt(this.zoom);e=e-d;e=e-f;e=e^(f>>>13);d=d-f;d=d-e;d=d^(e<<8);f=f-e;f=f-d;f=f^(d>>>13);e=e-d;e=e-f;e=e^(f>>>12);d=d-f;d=d-e;d=d^(e<<16);f=f-e;f=f-d;f=f^(d>>>5);e=e-d;e=e-f;e=e^(f>>>3);d=d-f;d=d-e;d=d^(e<<10);f=f-e;f=f-d;f=f^(d>>>15);return f},copy:function(){return new com.modestmaps.Coordinate(this.row,this.column,this.zoom)},container:function(){return new com.modestmaps.Coordinate(Math.floor(this.row),Math.floor(this.column),Math.floor(this.zoom))},zoomTo:function(a){var b=Math.pow(2,a-this.zoom);return new com.modestmaps.Coordinate(this.row*b,this.column*b,a)},zoomBy:function(b){var a=Math.pow(2,b);return new com.modestmaps.Coordinate(this.row*a,this.column*a,this.zoom+b)},up:function(a){if(a==undefined){a=1}return new com.modestmaps.Coordinate(this.row-a,this.column,this.zoom)},right:function(a){if(a==undefined){a=1}return new com.modestmaps.Coordinate(this.row,this.column+a,this.zoom)},down:function(a){if(a==undefined){a=1}return new com.modestmaps.Coordinate(this.row+a,this.column,this.zoom)},left:function(a){if(a==undefined){a=1}return new com.modestmaps.Coordinate(this.row,this.column-a,this.zoom)}};com.modestmaps.Location=function(a,b){this.lat=parseFloat(a);this.lon=parseFloat(b)};com.modestmaps.Location.prototype={lat:0,lon:0,toString:function(){return"("+this.lat.toFixed(3)+", "+this.lon.toFixed(3)+")"}};com.modestmaps.Transformation=function(c,e,a,b,d,f){this.ax=c;this.bx=e;this.cx=a;this.ay=b;this.by=d;this.cy=f};com.modestmaps.Transformation.prototype={ax:0,bx:0,cx:0,ay:0,by:0,cy:0,transform:function(a){return new com.modestmaps.Point(this.ax*a.x+this.bx*a.y+this.cx,this.ay*a.x+this.by*a.y+this.cy)},untransform:function(a){return new com.modestmaps.Point((a.x*this.by-a.y*this.bx-this.cx*this.by+this.cy*this.bx)/(this.ax*this.by-this.ay*this.bx),(a.x*this.ay-a.y*this.ax-this.cx*this.ay+this.cy*this.ax)/(this.bx*this.ay-this.by*this.ax))},deriveTransformation:function(k,j,e,d,a,n,g,f,c,b,m,l){var i=this.linearSolution(k,j,e,a,n,g,c,b,m);var h=this.linearSolution(k,j,d,a,n,f,c,b,l);return new com.modestmaps.Transformation(i[0],i[1],i[2],h[0],h[1],h[2])},linearSolution:function(f,o,i,e,n,h,d,m,g){f=parseFloat(f);o=parseFloat(o);i=parseFloat(i);e=parseFloat(e);n=parseFloat(n);h=parseFloat(h);d=parseFloat(d);m=parseFloat(m);g=parseFloat(g);var l=(((h-g)*(o-n))-((i-h)*(n-m)))/(((e-d)*(o-n))-((f-e)*(n-m)));var k=(((h-g)*(f-e))-((i-h)*(e-d)))/(((n-m)*(f-e))-((o-n)*(e-d)));var j=i-(f*l)-(o*k);return[l,k,j]}};com.modestmaps.Projection=function(b,a){if(!a){a=com.modestmaps.Transformation(1,0,0,0,1,0)}this.zoom=b;this.transformation=a};com.modestmaps.Projection.prototype={zoom:0,transformation:null,rawProject:function(a){alert("Abstract method not implemented by subclass.")},rawUnproject:function(a){alert("Abstract method not implemented by subclass.")},project:function(a){a=this.rawProject(a);if(this.transformation){a=this.transformation.transform(a)}return a},unproject:function(a){if(this.transformation){a=this.transformation.untransform(a)}a=this.rawUnproject(a);return a},locationCoordinate:function(b){var a=new com.modestmaps.Point(Math.PI*b.lon/180,Math.PI*b.lat/180);a=this.project(a);return new com.modestmaps.Coordinate(a.y,a.x,this.zoom)},coordinateLocation:function(b){b=b.zoomTo(this.zoom);var a=new com.modestmaps.Point(b.column,b.row);a=this.unproject(a);return new com.modestmaps.Location(180*a.y/Math.PI,180*a.x/Math.PI)}};com.modestmaps.LinearProjection=function(b,a){com.modestmaps.Projection.call(this,b,a)};com.modestmaps.LinearProjection.prototype={rawProject:function(a){return new com.modestmaps.Point(a.x,a.y)},rawUnproject:function(a){return new com.modestmaps.Point(a.x,a.y)}};com.modestmaps.extend(com.modestmaps.LinearProjection,com.modestmaps.Projection);com.modestmaps.MercatorProjection=function(b,a){com.modestmaps.Projection.call(this,b,a)};com.modestmaps.MercatorProjection.prototype={rawProject:function(a){return new com.modestmaps.Point(a.x,Math.log(Math.tan(0.25*Math.PI+0.5*a.y)))},rawUnproject:function(a){return new com.modestmaps.Point(a.x,2*Math.atan(Math.pow(Math.E,a.y))-0.5*Math.PI)}};com.modestmaps.extend(com.modestmaps.MercatorProjection,com.modestmaps.Projection);com.modestmaps.MapProvider=function(a){if(a){this.getTileUrl=a}};com.modestmaps.MapProvider.prototype={projection:new com.modestmaps.MercatorProjection(26,new com.modestmaps.Transformation(10680707.79,0,33554431.85,0,-10680708.9,33554430.57)),tileWidth:256,tileHeight:256,getTileUrl:function(a){alert("Abstract method not implemented by subclass.")},locationCoordinate:function(a){return this.projection.locationCoordinate(a)},coordinateLocation:function(a){return this.projection.coordinateLocation(a)},sourceCoordinate:function(b){var a=b.column%Math.pow(2,b.zoom);while(a<0){a+=Math.pow(2,b.zoom)}return new com.modestmaps.Coordinate(b.row,a,b.zoom)}};com.modestmaps.Map=function(b,e,c){if(typeof b=="string"){b=document.getElementById(b)}this.parent=b;this.idBase=b.id;this.parent.style.position="relative";this.parent.style.width=parseInt(c.x)+"px";this.parent.style.height=parseInt(c.y)+"px";this.parent.style.padding="0";this.parent.style.overflow="hidden";this.parent.style.backgroundColor="#eee";com.modestmaps.addEvent(this.parent,"dblclick",this.getDoubleClick());com.modestmaps.addEvent(this.parent,"mousedown",this.getMouseDown());com.modestmaps.addEvent(this.parent,"mousewheel",this.getMouseWheel());this.loadingLayer=document.createElement("div");this.loadingLayer.id=this.idBase+"loading layer";this.loadingLayer.style.display="none";this.parent.appendChild(this.loadingLayer);this.layers=[];for(var d=0;d<=20;d++){var a=document.createElement("div");a.id=this.idBase+"zoom-"+d;a.style.margin="0";a.style.padding="0";a.style.width="100%";a.style.height="100%";a.style.position="absolute";a.style.top="0px";a.style.left="0px";this.parent.appendChild(a);this.layers.push(a)}this.provider=e;this.dimensions=c;this.coordinate=new com.modestmaps.Coordinate(0.5,0.5,0);this.tiles={};this.requestedTiles={};this.requestCount=0;this.maxSimultaneousRequests=4;this.requestQueue=[];this.tileCacheSize=0;this.callbacks={zoomed:[],panned:[],centered:[],extentset:[]}};com.modestmaps.Map.prototype={parent:null,provider:null,dimensions:null,coordinate:null,tiles:null,requestedTiles:null,layers:null,requestCount:null,maxSimultaneousRequests:null,requestQueue:null,tileCacheSize:null,callbacks:null,toString:function(){return"Map("+this.provider.toString()+this.dimensions.toString()+this.coordinate.toString()+")"},addCallback:function(a,b){if(typeof(b)=="function"&&this.callbacks[a]){this.callbacks[a].push(b)}},dispatchCallback:function(c,b){if(this.callbacks[c]){for(var a=0;a<this.callbacks[c].length;a+=1){try{this.callbacks[c][a](this,b)}catch(d){}}}},createOverlay:function(b){var a=document.createElement("canvas");a.id=b;a.width=this.dimensions.x;a.height=this.dimensions.y;a.style.margin="0";a.style.padding="0";a.style.position="absolute";a.style.top="0px";a.style.left="0px";this.parent.appendChild(a)},mouseDownHandler:null,getMouseDown:function(){if(!this.mouseDownHandler){var a=this;this.mouseDownHandler=function(b){if(!b){var b=window.event}com.modestmaps.addEvent(document,"mouseup",a.getMouseUp());com.modestmaps.addEvent(document,"mousemove",a.getMouseMove());a.prevMouse=new com.modestmaps.Point(b.clientX,b.clientY);a.parent.style.cursor="move";return com.modestmaps.cancelEvent(b)}}return this.mouseDownHandler},mouseMoveHandler:null,getMouseMove:function(){if(!this.mouseMoveHandler){var a=this;this.mouseMoveHandler=function(b){if(!b){b=window.event}if(a.prevMouse){a.panBy(b.clientX-a.prevMouse.x,b.clientY-a.prevMouse.y);a.prevMouse.x=b.clientX;a.prevMouse.y=b.clientY}return com.modestmaps.cancelEvent(b)}}return this.mouseMoveHandler},mouseUpHandler:null,getMouseUp:function(){if(!this.mouseUpHandler){var a=this;this.mouseUpHandler=function(b){if(!b){b=window.event}com.modestmaps.removeEvent(document,"mouseup",a.getMouseUp());com.modestmaps.removeEvent(document,"mousemove",a.getMouseMove());a.prevMouse=null;a.parent.style.cursor="";return com.modestmaps.cancelEvent(b)}}return this.mouseUpHandler},mouseWheelHandler:null,getMouseWheel:function(){if(!this.mouseWheelHandler){var a=this;var b=new Date().getTime();this.mouseWheelHandler=function(f){if(!f){f=window.event}var g=0;if(f.wheelDelta){g=f.wheelDelta}else{if(f.detail){g=-f.detail}}var d=new Date().getTime()-b;if(g!=0&&(d>200)){var c=a.getMousePoint(f);a.zoomByAbout(g>0?1:-1,c);b=new Date().getTime()}return com.modestmaps.cancelEvent(f)}}return this.mouseWheelHandler},doubleClickHandler:null,getDoubleClick:function(){if(!this.doubleClickHandler){var a=this;this.doubleClickHandler=function(c){if(!c){c=window.event}var b=a.getMousePoint(c);a.zoomByAbout(c.shiftKey?-1:1,b);return com.modestmaps.cancelEvent(c)}}return this.doubleClickHandler},getMousePoint:function(c){var a=new com.modestmaps.Point(c.clientX,c.clientY);a.x+=document.body.scrollLeft+document.documentElement.scrollLeft;a.y+=document.body.scrollTop+document.documentElement.scrollTop;for(var b=this.parent;b;b=b.offsetParent){a.x-=b.offsetLeft;a.y-=b.offsetTop}return a},zoomIn:function(){this.zoomBy(1)},zoomOut:function(){this.zoomBy(-1)},setZoom:function(a){this.zoomBy(a-this.coordinate.zoom)},zoomBy:function(a){this.coordinate=this.coordinate.zoomBy(a);this.draw();this.dispatchCallback("zoomed",a)},zoomByAbout:function(b,a){var d=this.pointLocation(a);this.coordinate=this.coordinate.zoomBy(b);var c=this.locationPoint(d);this.panBy(a.x-c.x,a.y-c.y);this.dispatchCallback("zoomed",b)},panBy:function(b,a){this.coordinate.column-=b/this.provider.tileWidth;this.coordinate.row-=a/this.provider.tileHeight;this.draw();this.dispatchCallback("panned",[b,a])},panLeft:function(){this.panBy(100,0)},panRight:function(){this.panBy(-100,0)},panDown:function(){this.panBy(0,-100)},panUp:function(){this.panBy(0,100)},setCenter:function(a){this.setCenterZoom(a,this.coordinate.zoom)},setCenterZoom:function(a,b){this.coordinate=this.provider.locationCoordinate(a).zoomTo(b);this.draw();this.dispatchCallback("centered",[a,b])},setExtent:function(j){var g,f;for(var e=0;e<j.length;e++){var p=this.provider.locationCoordinate(j[e]);if(g){g.row=Math.min(g.row,p.row);g.column=Math.min(g.column,p.column);g.zoom=Math.min(g.zoom,p.zoom);f.row=Math.max(f.row,p.row);f.column=Math.max(f.column,p.column);f.zoom=Math.max(f.zoom,p.zoom)}else{g=p.copy();f=p.copy()}}var b=this.dimensions.x+1;var q=this.dimensions.y+1;var a=(f.column-g.column)/(b/this.provider.tileWidth);var k=Math.log(a)/Math.log(2);var l=g.zoom-Math.ceil(k);var m=(f.row-g.row)/(q/this.provider.tileHeight);var r=Math.log(m)/Math.log(2);var o=g.zoom-Math.ceil(r);var c=Math.min(l,o);var d=(g.row+f.row)/2;var h=(g.column+f.column)/2;var n=g.zoom;this.coordinate=new com.modestmaps.Coordinate(d,h,n).zoomTo(c);this.draw();this.dispatchCallback("extentset",j)},coordinatePoint:function(b){if(b.zoom!=this.coordinate.zoom){b=b.zoomTo(this.coordinate.zoom)}var a=new com.modestmaps.Point(this.dimensions.x/2,this.dimensions.y/2);a.x+=this.provider.tileWidth*(b.column-this.coordinate.column);a.y+=this.provider.tileHeight*(b.row-this.coordinate.row);return a},pointCoordinate:function(a){var b=this.coordinate.copy();b.column+=(a.x-this.dimensions.x/2)/this.provider.tileWidth;b.row+=(a.y-this.dimensions.y/2)/this.provider.tileHeight;return b},locationPoint:function(a){return this.coordinatePoint(this.provider.locationCoordinate(a))},pointLocation:function(a){return this.provider.coordinateLocation(this.pointCoordinate(a))},getExtent:function(){var a=[];a.push(this.pointLocation(new com.modestmaps.Point(0,0)));a.push(this.pointLocation(this.dimensions));return a},getCenter:function(){return this.provider.coordinateLocation(this.coordinate)},getZoom:function(){return this.coordinate.zoom},draw:function(p){var z=this.coordinate.container();var A=new com.modestmaps.Point(this.dimensions.x/2,this.dimensions.y/2);A.x+=(z.column-this.coordinate.column)*this.provider.tileWidth;A.y+=(z.row-this.coordinate.row)*this.provider.tileHeight;while(A.x>0){A.x-=this.provider.tileWidth;z.column-=1}while(A.y>0){A.y-=this.provider.tileHeight;z.row-=1}var c={};var f=this.layers[parseInt(z.zoom)];f.coordinate=this.coordinate.copy();var l=false;var b=z.copy();var s=this.dimensions.y;var t=this.dimensions.x;var e=this.provider.tileHeight;var n=this.provider.tileWidth;for(var h=A.y;h<s;h+=e){for(var k=A.x;k<t;k+=n){var g=b.toKey();c[g]=true;if(!this.tiles[g]){if(!this.requestedTiles[g]){this.requestTile(b)}l=true;if(!p){for(var m=1;m<=5;m++){var r=b.zoomBy(-m).container().toKey();c[r]=true}var d=b.zoomBy(1);c[d.toKey()]=true;d.column+=1;c[d.toKey()]=true;d.row+=1;c[d.toKey()]=true;d.column-=1;c[d.toKey()]=true}}else{var D=this.tiles[g];if(D.parentNode!=f){f.appendChild(D)}D.style.left=k+"px";D.style.top=h+"px"}b.column+=1}b.row+=1;b.column=z.column}if(!p||!l){for(var q=0;q<z.zoom-5;q++){var C=this.layers[q];C.style.display="none";var w=C.getElementsByTagName("img");for(var o=w.length-1;o>=0;o--){C.removeChild(w[o])}}for(var q=z.zoom+2;q<this.layers.length;q++){var C=this.layers[q];C.style.display="none";var w=C.getElementsByTagName("img");for(var o=w.length-1;o>=0;o--){C.removeChild(w[o])}}for(var q=Math.max(0,z.zoom-5);q<Math.min(z.zoom+2,this.layers.length);q++){var C=this.layers[q];var B=1;var a=null;if(C.coordinate){C.style.display="block";if(C!=f){a=this.coordinate.zoomTo(C.coordinate.zoom);B=Math.pow(2,this.coordinate.zoom-C.coordinate.zoom)}}else{C.style.display="none"}var w=C.getElementsByTagName("img");for(var o=w.length-1;o>=0;o--){var D=w[o];if(!c[D.id]){C.removeChild(D)}else{if(a){var v=((this.dimensions.x/2)+(D.coord.column-a.column)*this.provider.tileWidth*B);var u=((this.dimensions.y/2)+(D.coord.row-a.row)*this.provider.tileHeight*B);D.style.left=parseInt(v)+"px";D.style.top=parseInt(u)+"px";D.width=this.provider.tileWidth*B;D.height=this.provider.tileHeight*B}else{D.width=this.provider.tileWidth;D.height=this.provider.tileHeight}}}}}for(var g in this.requestedTiles){if(!c[g]){var D=this.requestedTiles[g];this.cancelTileRequest(D);D=null}}this.processQueue()},redrawTimer:undefined,requestRedraw:function(){if(this.redrawTimer){clearTimeout(this.redrawTimer)}this.redrawTimer=setTimeout(this.getRedraw(),1000)},_redraw:null,getRedraw:function(){if(!this._redraw){var a=this;this._redraw=function(){a.draw()}}return this._redraw},requestTile:function(a){var c=a.toKey();if(!this.requestedTiles[c]){var b=document.createElement("img");b.id=c;b.width=this.provider.tileWidth;b.height=this.provider.tileHeight;b.style.position="absolute";this.requestedTiles[c]=b;this.requestQueue.push({tile:b,coord:a.copy()})}},processQueue:function(){if(this.requestQueue.length>8){this.requestQueue.sort(this.getCenterDistanceCompare())}while(this.requestCount<this.maxSimultaneousRequests&&this.requestQueue.length>0){var a=this.requestQueue.pop();if(a){this.requestCount++;this.loadingLayer.appendChild(a.tile);a.tile.onload=a.tile.onerror=this.getLoadComplete();a.tile.src=this.provider.getTileUrl(a.coord);a.tile.coord=a.coord;a.tile=a.coord=null}}},cancelTileRequest:function(c){delete this.requestedTiles[c.id];if(c.src){c.onload=c.onerror=null;c.coord=null;c.src=null;this.loadingLayer.removeChild(c);this.requestCount--}else{for(var a=0;a<this.requestQueue.length;a++){var b=this.requestQueue[a];if(b&&b.tile===c){this.requestQueue[a]=null;b.tile=b.coord=null}}}},_loadComplete:null,getLoadComplete:function(){if(!this._loadComplete){var a=this;this._loadComplete=function(c){if(!c){var c=event||window.event}var b=c.srcElement||c.target;b.onload=b.onerror=null;a.loadingLayer.removeChild(b);a.requestCount--;delete a.requestedTiles[b.id];if(b.complete||(b.readyState&&b.readyState=="complete")){a.tiles[b.id]=b;a.tileCacheSize++}else{b.src=null}a.draw(true);a.requestRedraw()}}return this._loadComplete},getCenterDistanceCompare:function(){var a=this.coordinate;return function(d,c){if(d&&c){var f=d.coord;var e=c.coord;var b=Math.abs(a.row-f.row)+Math.abs(a.column-f.column);var g=Math.abs(a.row-e.row)+Math.abs(a.column-e.column);return b<g?1:b>g?-1:0}return d?1:c?-1:0}}};
View
140 tools/README
@@ -0,0 +1,140 @@
+==============================================================================
+YUI Compressor
+==============================================================================
+
+NAME
+
+ YUI Compressor - The Yahoo! JavaScript and CSS Compressor
+
+SYNOPSIS
+
+ Usage: java -jar yuicompressor-x.y.z.jar [options] [input file]
+
+ Global Options
+ -h, --help Displays this information
+ --type <js|css> Specifies the type of the input file
+ --charset <charset> Read the input file using <charset>
+ --line-break <column> Insert a line break after the specified column number
+ -v, --verbose Display informational messages and warnings
+ -o <file> Place the output into <file>. Defaults to stdout.
+
+ JavaScript Options
+ --nomunge Minify only, do not obfuscate
+ --preserve-semi Preserve all semicolons
+ --disable-optimizations Disable all micro optimizations
+
+DESCRIPTION
+
+ The YUI Compressor is a JavaScript compressor which, in addition to removing
+ comments and white-spaces, obfuscates local variables using the smallest
+ possible variable name. This obfuscation is safe, even when using constructs
+ such as 'eval' or 'with' (although the compression is not optimal is those
+ cases) Compared to jsmin, the average savings is around 20%.
+
+ The YUI Compressor is also able to safely compress CSS files. The decision
+ on which compressor is being used is made on the file extension (js or css)
+
+GLOBAL OPTIONS
+
+ -h, --help
+ Prints help on how to use the YUI Compressor
+
+ --line-break
+ Some source control tools don't like files containing lines longer than,
+ say 8000 characters. The linebreak option is used in that case to split
+ long lines after a specific column. It can also be used to make the code
+ more readable, easier to debug (especially with the MS Script Debugger)
+ Specify 0 to get a line break after each semi-colon in JavaScript, and
+ after each rule in CSS.
+
+ --type js|css
+ The type of compressor (JavaScript or CSS) is chosen based on the
+ extension of the input file name (.js or .css) This option is required
+ if no input file has been specified. Otherwise, this option is only
+ required if the input file extension is neither 'js' nor 'css'.
+
+ --charset character-set
+ If a supported character set is specified, the YUI Compressor will use it
+ to read the input file. Otherwise, it will assume that the platform's
+ default character set is being used. The output file is encoded using
+ the same character set.
+
+ -o outfile
+ Place output in file outfile. If not specified, the YUI Compressor will
+ default to the standard output, which you can redirect to a file.
+
+ -v, --verbose
+ Display informational messages and warnings.
+
+JAVASCRIPT ONLY OPTIONS
+
+ --nomunge
+ Minify only. Do not obfuscate local symbols.
+
+ --preserve-semi
+ Preserve unnecessary semicolons (such as right before a '}') This option
+ is useful when compressed code has to be run through JSLint (which is the
+ case of YUI for example)
+
+ --disable-optimizations
+ Disable all the built-in micro optimizations.
+
+NOTES
+
+ + If no input file is specified, it defaults to stdin.
+
+ + The YUI Compressor requires Java version >= 1.4.
+
+ + It is possible to prevent a local variable, nested function or function
+ argument from being obfuscated by using "hints". A hint is a string that
+ is located at the very beginning of a function body like so:
+
+ function fn (arg1, arg2, arg3) {
+ "arg2:nomunge, localVar:nomunge, nestedFn:nomunge";
+
+ ...
+ var localVar;
+ ...
+
+ function nestedFn () {
+ ....
+ }
+
+ ...
+ }
+
+ The hint itself disappears from the compressed file.
+
+ + C-style comments starting with /*! are preserved. This is useful with
+ comments containing copyright/license information. For example:
+
+ /*!
+ * TERMS OF USE - EASING EQUATIONS
+ * Open source under the BSD License.
+ * Copyright 2001 Robert Penner All rights reserved.
+ */
+
+ becomes:
+
+ /*
+ * TERMS OF USE - EASING EQUATIONS
+ * Open source under the BSD License.
+ * Copyright 2001 Robert Penner All rights reserved.
+ */
+
+AUTHOR
+
+ The YUI Compressor was written and is maintained by:
+ Julien Lecomte <jlecomte@yahoo-inc.com>
+ The CSS portion is a port of Isaac Schlueter's cssmin utility.
+
+COPYRIGHT
+
+ Copyright (c) 2007-2009, Yahoo! Inc. All rights reserved.
+
+LICENSE
+
+ All code specific to YUI Compressor is issued under a BSD license.
+ YUI Compressor extends and implements code from Mozilla's Rhino project.
+ Rhino is issued under the Mozilla Public License (MPL), and MPL applies
+ to the Rhino source and binaries that are distributed with YUI Compressor.
View
BIN  tools/yuicompressor-2.4.2.jar
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.