Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Started to gut out the old dynamic GMaps API calls, hooked in new dev…

…ice events from PhoneGap.
  • Loading branch information...
commit 2606935ae885b36b012529acf81727b2b071207b 1 parent edc3c9c
@filmaj filmaj authored
Showing with 24 additions and 47 deletions.
  1. +17 −22 assets/beerme.js
  2. +7 −25 assets/index.html
View
39 assets/beerme.js
@@ -1,15 +1,7 @@
// Beer Me JS code.
var BeerMe = {
- // Create our droid and beer marker icon
- droidIcon:new GIcon(G_DEFAULT_ICON),
- droidMarkerOptions:null,
- beerIcon:new GIcon(G_DEFAULT_ICON),
- beerMarkerOptions:null,
- myMarkerInfo:document.createElement("div"),
- myMarker:null,
- beerMarkers:[],
- map:null,
- geocoder:null,
+ init:function() {
+ },
disableRefresh:function() {
var btn = document.getElementById('refreshBtn');
btn.disabled = true;
@@ -161,15 +153,18 @@ var BeerMe = {
BeerMe.getBeerFromBeerMapping(lat,lng);
}
};
-BeerMe.droidIcon.image = "images/androidmarker.png";
-BeerMe.droidIcon.iconSize = new GSize(50,58);
-BeerMe.droidMarkerOptions = { icon:BeerMe.droidIcon };
-BeerMe.beerIcon.image = "images/beericon.png";
-BeerMe.beerIcon.iconSize = new GSize(40,45);
-BeerMe.beerMarkerOptions = { icon:BeerMe.beerIcon };
-BeerMe.myMarkerInfo.innerHTML = 'Your position';
-BeerMe.myMarker = new GMarker(new GLatLng(0,0), BeerMe.droidMarkerOptions);
-GEvent.addListener(BeerMe.myMarker, "click", function() {
- var myHtml = "<b>Your position</b>";
- BeerMe.myMarker.openInfoWindowHtml(myHtml);
-});
+
+// Geolocation code shamelessly stolen from Movable Type scripts: http://www.movable-type.co.uk/scripts/latlong.html
+LatLon.distCosineLaw = function(lat1, lon1, lat2, lon2) {
+ var R = 6371; // earth's mean radius in km
+ var d = Math.acos(Math.sin(lat1.toRad())*Math.sin(lat2.toRad()) +
+ Math.cos(lat1.toRad())*Math.cos(lat2.toRad())*Math.cos((lon2-lon1).toRad())) * R;
+ return d;
+};
+function LatLon(lat, lon) {
+ this.lat = lat;
+ this.lon = lon;
+}
+Number.prototype.toRad = function() { // convert degrees to radians
+ return this * Math.PI / 180;
+};
View
32 assets/index.html
@@ -3,37 +3,19 @@
<head>
<meta name="viewport" content="width=device-width; height=device-height; user-scalable=no" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
- <title>PhoneGap</title>
+ <title>Beer Me</title>
<link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title" charset="utf-8">
<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
- <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAASWkdhwcFZHCle_XL8gNI0hQQPTIxowtQGbc0PVHZZ3XLXr5GBhRKV3t_-63J9ZAJ2bYu3zsQdR9N-A&sensor=true" type="text/javascript"></script>
<script type="text/javascript" src="yql_js_widget.js"></script>
<script type="text/javascript" src="beerme.js"></script>
- <script type="text/javascript" charset="utf-8">
- // Geolocation code shamelessly stolen from Movable Type scripts: http://www.movable-type.co.uk/scripts/latlong.html
- LatLon.distCosineLaw = function(lat1, lon1, lat2, lon2) {
- var R = 6371; // earth's mean radius in km
- var d = Math.acos(Math.sin(lat1.toRad())*Math.sin(lat2.toRad()) +
- Math.cos(lat1.toRad())*Math.cos(lat2.toRad())*Math.cos((lon2-lon1).toRad())) * R;
- return d;
- };
- function LatLon(lat, lon) {
- this.lat = lat;
- this.lon = lon;
- }
- Number.prototype.toRad = function() { // convert degrees to radians
- return this * Math.PI / 180;
- };
-
- function initialize() {
- BeerMe.map = new GMap2(document.getElementById("map_canvas"));
- BeerMe.map.addControl(new GLargeMapControl);
- BeerMe.geocoder = new GClientGeocoder();
- BeerMe.updateLocation();
- }
+ <script type="text/javascript">
+ function init() {
+ document.addEventListener("touchmove", preventBehavior, false);
+ document.addEventListener("deviceReady", BeerMe.init, true);
+ }
</script>
</head>
- <body onload="/*TODO: Check for GPS/Internet availability.*/setTimeout('initialize()',2500)" onunload="GUnload()" id="stage" class="theme">
+ <body onload="init();" id="stage" class="theme">
<div id="map_cont" style="width:100%;padding:2px;height:279px;">
<div id="map_canvas" style="width:100%;height:100%;z-index:1;"></div>
</div>
Please sign in to comment.
Something went wrong with that request. Please try again.