Skip to content

Commit

Permalink
Adding geocoder draft (doesn't work yet) and Fixing cutting-room-floo…
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom MacWright committed May 17, 2011
1 parent c4b92ce commit 625b6e9
Show file tree
Hide file tree
Showing 6 changed files with 206 additions and 15 deletions.
59 changes: 59 additions & 0 deletions build/wax.mm.js
Expand Up @@ -1718,6 +1718,65 @@ com.modestmaps.Map.prototype.minimize = function(e) {
this.smallSize[0],
this.smallSize[1]);
};
// Wax: Geocoder
// -------------

// namespacing!
if (!com) {
var com = { };
if (!com.modestmaps) {
com.modestmaps = { };
}
}

com.modestmaps.Map.prototype.geocoder = function(opts) {
var mouseDownPoint = null,
mouseUpPoint = null,
map = this,
tolerance = 5,
MM = com.modestmaps,
locations = [];

var callback = (typeof opts === 'function') ?
opts :
opts.callback;


var overlayDiv = document.createElement('div');
overlayDiv.id = this.parent.id + '-boxselector';
overlayDiv.className = 'pointselector-box-container';
overlayDiv.style.width = this.dimensions.x + 'px';
overlayDiv.style.height = this.dimensions.y + 'px';
this.parent.appendChild(overlayDiv);

var makePoint = function(e) {
var point = new MM.Point(e.clientX, e.clientY);
// correct for scrolled document
point.x += document.body.scrollLeft + document.documentElement.scrollLeft;
point.y += document.body.scrollTop + document.documentElement.scrollTop;

// correct for nested offsets in DOM
for (var node = map.parent; node; node = node.offsetParent) {
point.x -= node.offsetLeft;
point.y -= node.offsetTop;
}
return point;
};

var pointselector = {
deletePoint: function(location, e) {
if (confirm('Delete this point?')) {
// TODO: indexOf not supported in IE
location.pointDiv.parentNode.removeChild(location.pointDiv);
locations.splice(locations.indexOf(location), 1);
callback(locations);
}
}
};
MM.addEvent(overlayDiv, 'mousedown', pointselector.mouseDown);
map.addCallback('drawn', pointselector.drawPoints);
return this;
};
// namespacing!
if (!com) {
var com = { };
Expand Down
2 changes: 1 addition & 1 deletion build/wax.mm.min.js

Large diffs are not rendered by default.

59 changes: 59 additions & 0 deletions control/mm/geocoder.js
@@ -0,0 +1,59 @@
// Wax: Geocoder
// -------------

// namespacing!
if (!com) {
var com = { };
if (!com.modestmaps) {
com.modestmaps = { };
}
}

com.modestmaps.Map.prototype.geocoder = function(opts) {
var mouseDownPoint = null,
mouseUpPoint = null,
map = this,
tolerance = 5,
MM = com.modestmaps,
locations = [];

var callback = (typeof opts === 'function') ?
opts :
opts.callback;


var overlayDiv = document.createElement('div');
overlayDiv.id = this.parent.id + '-boxselector';
overlayDiv.className = 'pointselector-box-container';
overlayDiv.style.width = this.dimensions.x + 'px';
overlayDiv.style.height = this.dimensions.y + 'px';
this.parent.appendChild(overlayDiv);

var makePoint = function(e) {
var point = new MM.Point(e.clientX, e.clientY);
// correct for scrolled document
point.x += document.body.scrollLeft + document.documentElement.scrollLeft;
point.y += document.body.scrollTop + document.documentElement.scrollTop;

// correct for nested offsets in DOM
for (var node = map.parent; node; node = node.offsetParent) {
point.x -= node.offsetLeft;
point.y -= node.offsetTop;
}
return point;
};

var pointselector = {
deletePoint: function(location, e) {
if (confirm('Delete this point?')) {
// TODO: indexOf not supported in IE
location.pointDiv.parentNode.removeChild(location.pointDiv);
locations.splice(locations.indexOf(location), 1);
callback(locations);
}
}
};
MM.addEvent(overlayDiv, 'mousedown', pointselector.mouseDown);
map.addCallback('drawn', pointselector.drawPoints);
return this;
};
61 changes: 48 additions & 13 deletions manual/index.html
@@ -1,22 +1,27 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Wax Manual</title>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Wax Manual</title>
<script src='lib/jquery.js' type='text/javascript'></script>
<script src='../ext/modestmaps.js' type='text/javascript'></script>
<script src='../build/wax.mm.js' type='text/javascript'></script>
<script src='lib/showdown.js' type='text/javascript'></script>
<script src='lib/shjs.js' type='text/javascript'></script>
<script src='lib/sh_javascript.min.js' type='text/javascript'></script>
<script src='site.js' type='text/javascript'></script>
<link href='lib/shjs.css' rel='stylesheet' type='text/css' />
<link href='../theme/controls.css' rel='stylesheet' type='text/css' />
<link href='site.css' rel='stylesheet' type='text/css' />
</head>
<body>
<div class='page'>
<link href='lib/shjs.css' rel='stylesheet' type='text/css' />
<link href='../theme/controls.css' rel='stylesheet' type='text/css' />
<link href='site.css' rel='stylesheet' type='text/css' />
</head>
<body>
<div class='page'>

<div class='navigation'>
<ul></ul>
</div>

<p class='md'>
## Publishing Maps

Expand Down Expand Up @@ -171,7 +176,7 @@
### Zoomer

The Zoomer control is a stripped-down version of zoom controls, offering just
zoom in & out buttons.
zoom in &amp; out buttons.
</p>

<div class='section'>
Expand Down Expand Up @@ -277,10 +282,40 @@
</pre>
</div>


<p class='md'>
### geocoder
</p>

<div class='section'>
<div id='modestmaps-geocoder' class='map dark'>
<span class='attribution'>
<a href='http://mapbox.com/tileset/world-glass'>World Glass</a>
</span>
</div>
<pre class='sh_javascript run'>
var mm = com.modestmaps;
var m = new mm.Map('modestmaps-geocoder',
new com.modestmaps.WaxProvider({
baseUrl: 'http://a.tiles.mapbox.com/mapbox/',
layerName: 'blue-marble-topo-bathy-jul'}), new mm.Point(448,300))
.pointselector(function(coords) {
$('#modestmaps-pointselector .attribution').text(
coords.map(function(c) {
return c.lat + ',' + c.lon;
}).join(' - '));
})
.geocoder(function() { console.log(arguments); });
m.setCenterZoom(
new com.modestmaps.Location(38.8225909, -97.5585),
2);
</pre>
</div>

<p class='md'>
### Legend

The legend control pulls legend information from an interactive layer and
The legend control pulls legend information from an interactive layer and
displays it on the map.
</p>

Expand Down
29 changes: 29 additions & 0 deletions manual/site.css
Expand Up @@ -64,6 +64,35 @@ code {
padding:1px 3px;
}

.navigation {
position:fixed;
top:10px;
left:10px;
}

.navigation ul {
list-style-type:none;
margin:0;
padding:0;
}
.navigation ul li a {
text-decoration:none;
}
.navigation ul li a:hover {
text-decoration:underline;
}
.navigation ul li {
padding:0px;
font:normal 12px/18px 'Andale Mono',Monaco,Consolas,'Lucida Console',monospace;
}
.navigation ul li.H2 {
font-weight:bold;
}
.navigation ul li.H3 {
padding-left:3px;
}


/**
* This page's style
*/
Expand Down
11 changes: 10 additions & 1 deletion manual/site.js
@@ -1,6 +1,7 @@
// Application bootstrap.
$(function() {
// Convert any markdown sections to HTML.
var nav = $('.navigation ul');
$('.md').each(function() {
var html = document.createElement('div');
html.innerHTML = (new Showdown.converter()).makeHtml(this.innerHTML);
Expand All @@ -11,10 +12,18 @@ $(function() {
$('h1, h2, h3, h4, h5, h6', html).each(function() {
this.id = this.innerText.replace(/[\s\W]+/g, '-').toLowerCase();

var para = document.createElement('a');
var para = document.createElement('a'),
sectionLi = document.createElement('li'),
sectionA = document.createElement('a');

para.innerHTML = '&para;'
para.className = 'para'
para.href = '#' + this.id;
sectionA.href = '#' + this.id;
sectionA.innerText = this.innerText;
sectionLi.className = this.nodeName;
sectionLi.appendChild(sectionA);
nav.append(sectionLi);

this.appendChild(para);
});
Expand Down

0 comments on commit 625b6e9

Please sign in to comment.