Permalink
Browse files

changed drop-down to radio

  • Loading branch information...
1 parent 1fdf916 commit 36b50c1c1aec009bb679abdee328327645238e63 @wildabeast wildabeast committed Jun 17, 2010
View
26 04c - javascript - geolocation and google maps/application.js
@@ -22,24 +22,24 @@ function loadItUp(initializationFunction) {
function appInit() {
// there are 4 interaction points in the app:
// "Show My Location" button (welcome view)
- document.getElementById('map_button').ontouchend = function () {
+ document.getElementById('map_button').onclick = function () {
displayView('map');
navigator.geolocation.getCurrentPosition(displayGoogleMap);
}
// "Settings" button (welcome view)
- document.getElementById('settings_button').ontouchend = function () {
+ document.getElementById('settings_button').onclick = function () {
displayView('settings');
}
// "Go Back" button (map view)
- document.getElementById('back_button').ontouchend = function () {
+ document.getElementById('back_button').onclick = function () {
displayView('welcome');
}
// "Save" button (settings view)
// we want to override the default behaviour, so we return false
- document.getElementById('save_button').ontouchend = function () {
+ document.getElementById('save_button').onclick = function () {
displayView('welcome');
return false;
}
@@ -82,13 +82,25 @@ function isNetworkAvailable(status) {
// replacing the placeholder image with an image based on the given location
function displayGoogleMap(position) {
var location = "" + position.coords.latitude + "," + position.coords.longitude;
- var mapType = document.getElementById('map_type').value;
- var zoomLevel = document.getElementById('zoom_level').value;
+ var mapType = get_radio_value(document.getElementById('settings_form').map_type);
+ var zoomLevel = get_radio_value(document.getElementById('settings_form').zoom_level);
var mapPath = " http://maps.google.com/maps/api/staticmap?center=" +
location + "&zoom=" + zoomLevel +
"&size=250x250&maptype=" + mapType + "&markers=color:red|label:P|" +
location + "&sensor=false";
+ debug.log(mapPath);
document.getElementById("static_map").src = mapPath;
-}
+}
+
+function get_radio_value(radEl)
+{
+for (var i=0; i < radEl.length; i++)
+ {
+ if (radEl[i].checked)
+ {
+ return radEl[i].value;
+ }
+ }
+}
View
24 04c - javascript - geolocation and google maps/index.html
@@ -4,6 +4,7 @@
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width" />
<title>Training App</title>
<link rel="stylesheet" href="master.css" type="text/css" media="screen" />
+ <script language="javascript" type="text/javascript" src="/usr/palm/frameworks/mojo/mojo.js" x-mojo-version="1"></script>
<script type="text/javascript" src="phonegap.js"></script>
<script type="text/javascript" src="application.js"></script>
</head>
@@ -18,7 +19,7 @@
<div id="map" class="view">
<div class="map_image">
- <img id="static_map" src="staticmap.png">
+ <img id="static_map" src="staticmap.png" />
</div>
<p>This is where you are</p>
@@ -28,19 +29,16 @@
<div id="settings" class="view">
<form id="settings_form">
<p>Map Type</p>
- <select id="map_type">
- <option value="roadmap">Road Map</option>
- <option value="satellite">Satellite</option>
- <option value="terrain">Terrain</option>
- <option value="hybrid">Hybrid</option>
- </select>
+ <input type="radio" name="map_type" value="roadmap" checked>Road Map<br/>
+ <input type="radio" name="map_type" value="satellite">Satellite<br/>
+ <input type="radio" name="map_type" value="terrain">Terrain<br/>
+ <input type="radio" name="map_type" value="hybrid">Hybrid<br/>
<p>Zoom Level</p>
- <select id="zoom_level">
- <option value="10">Super Far</option>
- <option value="12">Far</option>
- <option value="15" selected>Normal</option>
- <option value="18">Close</option>
- <option value="20">Super Close</option>
+ <input type="radio" name="zoom_level" value="10">Super Far<br/>
+ <input type="radio" name="zoom_level" value="12">Far<br/>
+ <input type="radio" name="zoom_level" value="15" checked>Normal<br/>
+ <input type="radio" name="zoom_level" value="18">Close<br/>
+ <input type="radio" name="zoom_level" value="20">Super Close<br/>
</select><br>
<button id="save_button">Save</button>
</form>

0 comments on commit 36b50c1

Please sign in to comment.