forked from cutting-room-floor/wax
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding geocoder draft (doesn't work yet) and Fixing cutting-room-floo…
- Loading branch information
Tom MacWright
committed
May 17, 2011
1 parent
c4b92ce
commit 625b6e9
Showing
6 changed files
with
206 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters