Permalink
Browse files

Added a close button to results dialog, changed the clear button to c…

…lear features, cleared the coords array after calculting to fix issues on subsequent calls
  • Loading branch information...
TankofVines committed Aug 29, 2012
1 parent f9210db commit f58c484118c324a18b91cfe2df744f3692e8c7cb
Showing with 40 additions and 20 deletions.
  1. +6 −0 css/ppa.css
  2. +27 −17 js/ppa.js
  3. +7 −3 ppamobile.html
View
@@ -16,3 +16,9 @@ body {
#results-link {
display: none;
}
+
+#dialog-close-button {
+ width: 150px;
+ margin: 2px;
+ float: right;
+}
View
@@ -3,37 +3,40 @@ var coords = [];
var proj = L.Projection.Mercator;
function initMap() {
- // Leaflet Map
+ // New leaflet Map
map = new L.Map('map', {
doubleClickZoom: false
});
// Initial location
var intialPoint = new L.LatLng(27.841845, -82.598578);
- var geojsonFeature = {
- "type": "Feature",
- "properties": {
- "name": "Weedon Island Preserve",
- "amenity": "Cultural Resource",
- "popupContent": "Welcome to Weedon Island Preserve!"
- },
- "geometry": {
- "type": "Point",
- "coordinates": [-82.598578, 27.841845]
- }
- };
+ // var geojsonFeature = {
+ // "type": "Feature",
+ // "properties": {
+ // "name": "Weedon Island Preserve",
+ // "amenity": "Cultural Resource",
+ // "popupContent": "Welcome to Weedon Island Preserve!"
+ // },
+ // "geometry": {
+ // "type": "Point",
+ // "coordinates": [-82.598578, 27.841845]
+ // }
+ // };
// OSM
var streetMapUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
var streetMapLayer = new L.TileLayer(streetMapUrl, { maxZoom: 19, attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>' });
-
+
+ // Set the intitial zoom level and center location
map.setView(intialPoint, 14);
map.addLayer(streetMapLayer);
+ // Create feature editor for use in the function below
var editFeatures = L.geoJson().addTo(map);
- editFeatures.addData(geojsonFeature);
-
+ // editFeatures.addData(geojsonFeature);
+
+ // Function to add points to the map on click
function addPoint(e) {
var thisPoint = {
@@ -54,6 +57,13 @@ function initMap() {
map.on('click', addPoint);
+ $('#clear-button').click(function() {
+ editFeatures.clearLayers();
+
+ });
+
+ // On click event for the calculate button
+ // Project coordinates and call the node.js service
$('#calculateButton').click(function() {
editFeatures.eachLayer(function(layer) {
console.log(proj.project(layer.getLatLng()));
@@ -71,8 +81,8 @@ function initMap() {
},
dataType: "jsonp",
success: function(responseData) {
- // Do something with the response......................
console.log(responseData);
+ coords = [];
// alert(responseData);
$("#results-content").html('<p>Mean nearest neighbor distance: ' + responseData + ' meters</p>');
$("#results-link").click();
View
@@ -16,7 +16,8 @@
<div data-role="page">
<div data-role="header">
- <a href="ppamobile.html" data-icon="" onClick="window.location.reload()">Clear</a>
+ <!-- <a id="clear-button" href="ppamobile.html" data-icon="">Clear</a> -->
+ <input id="clear-button" data-role="button" type="reset" value="Clear" class="ui-btn-left" data-inline="true" data-mini="true"/>
<h1 id="heading">Weedon Island Potsherd Monitoring Tool</h1>
<!-- <input id="calculateButton" type="submit" value="Calculate" class="ui-btn-right" data-mini="true" data-inline="true"/> -->
<a data-role="button" id="calculateButton" class="ui-btn-right">
@@ -33,8 +34,11 @@ <h1 id="heading">Weedon Island Potsherd Monitoring Tool</h1>
<div id="results-dialog" data-role="page">
<div data-role="header">
<h2>Results</h2>
- <div id="results-content" data-role="content">
- </div>
+ </div>
+ <div id="results-content" data-role="content">
+ </div>
+ <div data-role="footer" id="results-dialog-footer">
+ <a id="dialog-close-button" data-role="button" data-inline="false" href="ppamobile.html">OK</a>
</div>
</div>
</body>

0 comments on commit f58c484

Please sign in to comment.