Skip to content

Commit

Permalink
Tagging SnapToRoute 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pamela.fox committed Aug 20, 2009
1 parent f2c7aed commit 39c7a28
Show file tree
Hide file tree
Showing 386 changed files with 10 additions and 48,920 deletions.
4 changes: 1 addition & 3 deletions snaptoroute/docs/examples.html → 1.0/docs/examples.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,11 @@ <h2>Basic: Zoom to Polyline</h2>


<a name="advanced"></a>
<h2>Advanced: Printing Distance Along a Route and Starting / Stopping the class</h2>
<h2>Advanced: Printing Distance Along a Route</h2>

<p>In this example, we let the user click the map to create a path, and then display
the distance along the route for the marker in a status div.
</p>
<p>You can also use the right mousebutton to click on the map to stop and restart the snapping.
</p>
<p>The code below is called after a map click event. It either creates a new <code>SnapToRoute</code> object if none exists, or it just updates the existing object with the changed line.</p>
<pre class="prettyprint">
routeVertices.push(vertex);
Expand Down
24 changes: 2 additions & 22 deletions snaptoroute/docs/reference.html → 1.0/docs/reference.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,6 @@ <h3>Methods</h3>
of the closest point on route to test lat/lng.</td>
</tr>

<tr class="odd">
<td><code>start()</code></td>


<td><code>None</code></td>


<td>Restart snapping the marker to the route.</td>
</tr>

<tr class="even">
<td><code>stop()</code></td>


<td><code>None</code></td>


<td>Stop snapping the marker to the route.</td>
</tr>

<tr class="odd">
<td><code>updateTargets(<span class="type">marker:GMarker</span>, <span class="type">polyline:GPolyline</span>)</code></td>

Expand All @@ -111,10 +91,10 @@ <h3>Methods</h3>
</table>


<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
<!-- <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
<script type="text/javascript">
_uacct = "UA-964209-4";
urchinTracker();
</script>
</script> -->
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,17 @@
var threshold = 15; //pixels for proximity
var snapToRoute;

var listeningMap = true;

function load() {
map = new GMap2(document.getElementById("map"), {draggableCursor:"crosshair"});
map.setCenter(centerPoint, 7);
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
GEvent.addListener(map, 'click', mapClick);
GEvent.addListener(map, 'mousemove', mouseMove);

GEvent.addListener(map, 'singlerightclick', startStopSnap)

}


function startStopSnap(){
if ( listeningMap ){
snapToRoute.stop();
listeningMap = false;
} else {
snapToRoute.start();
listeningMap = true;
}
}

function mapClick(overlay, latlng) {
if (routeVertices.length > 3){
snapToRoute.stop();
}
if (!overlay) {
addRouteVertex(latlng);
}
Expand Down Expand Up @@ -103,7 +85,7 @@
</head>
<body onload="load()" onunload="GUnload()">
<div id="msg" style="width: 680px; font: bold 12px verdana;padding:3px;margin:10px;">
Click the map two or more times to create polylines. The marker wil snap to the polyline at all times. Use your right mouse button to start/stop the snapping to the line.
Click the map two or more times to create polylines. The marker wil snap to the polyline at all times.
</div>
<table cellspacing="0" cellpadding="0" style="-moz-outline-width:8px; -moz-outline-radius:15px; -moz-outline-style:solid;-moz-outline-color:#838FBB;margin:20px;">
<tr>
Expand Down
File renamed without changes.
File renamed without changes
29 changes: 5 additions & 24 deletions snaptoroute/src/snaptoroute.js → 1.0/src/snaptoroute.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* and by Bill Chadwick to factor the basic algorithm out of the class and add distance along line
* to nearest point calculation.
* -->
**/
*/


/**
Expand Down Expand Up @@ -57,34 +57,15 @@ SnapToRoute.prototype.updateTargets = function (marker, polyline) {
};


/**
* Stop snapping the marker to the route.
*/
SnapToRoute.prototype.stop = function () {
GEvent.removeListener(this.mousemoveListener);
};

/**
* Restart snapping the marker to the route.
*/
SnapToRoute.prototype.start = function () {
var me = this;
this.mousemoveListener = GEvent.addListener(me.map_, 'mousemove',
GEvent.callback(me, me.updateMarkerLocation_));
};




/**
* Set up map listeners to calculate and update the marker position.
* @private
*/
SnapToRoute.prototype.loadMapListener_ = function () {
var me = this;
this.mousemoveListener = GEvent.addListener(me.map_, 'mousemove',
GEvent.addListener(me.map_, 'mousemove',
GEvent.callback(me, me.updateMarkerLocation_));
this.zoomendListener = GEvent.addListener(me.map_, 'zoomend',
GEvent.addListener(me.map_, 'zoomend',
GEvent.callback(me, me.loadLineData_));
};

Expand Down Expand Up @@ -134,7 +115,7 @@ SnapToRoute.prototype.getClosestLatLng = function (latlng) {
* @return {Number} Distance in meters;
*/
SnapToRoute.prototype.getDistAlongRoute = function (latlng) {
if (typeof(latlng) === 'undefined') {
if (typeof(opt_latlng) === 'undefined') {
latlng = this.marker_.getLatLng();
}

Expand Down Expand Up @@ -249,4 +230,4 @@ SnapToRoute.prototype.getClosestPointOnLines_ = function (pXy, aXys) {
}

return {'x': x, 'y': y, 'i': i, 'to': to, 'from': from};
};
}
1 change: 1 addition & 0 deletions 1.0/src/snaptoroute_packed.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 39c7a28

Please sign in to comment.