From fb91f127d8682c24311e01290e53dcabeaeeb05b Mon Sep 17 00:00:00 2001 From: Vincent Bortone Date: Wed, 6 Mar 2013 02:20:35 -0500 Subject: [PATCH] Added Google Geolcation --- README.md | 2 +- google.geolocation/google.geolocation-tests.ts | 18 ++++++++++++++++++ google.geolocation/google.geolocation.d.ts | 12 ++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 google.geolocation/google.geolocation-tests.ts create mode 100644 google.geolocation/google.geolocation.d.ts diff --git a/README.md b/README.md index 1ebee9ccafd66a..1377dce5317b6b 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ List of Definitions * [glDatePicker](http://glad.github.com/glDatePicker/) (by [D�niel Tar](https://github.com/qcz)) * [GreenSock Animation Platform (GSAP)](http://www.greensock.com/get-started-js/) (by [Robert S.](https://github.com/codeBelt)) * [GoogleMaps](https://developers.google.com/maps/) (by [Esben Nepper](https://github.com/eNepper)) +* [Google Geolocation](https://code.google.com/p/geo-location-javascript/) (by [Vincent Bortone](https://github.com/vbortone)) * [Hammer.js](http://eightmedia.github.com/hammer.js/) (by [Boris Yankov](https://github.com/borisyankov)) * [Handlebars](http://handlebarsjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) * [Highcharts](http://www.highcharts.com/) (by [damianog](https://github.com/damianog)) @@ -161,4 +162,3 @@ Requested Definitions * [Prelude.ls](http://gkz.github.com/prelude-ls/) * [MooTools](http://mootools.net/) * [Lo-Dash](http://lodash.com/) -* [Google geolocation](https://code.google.com/p/geo-location-javascript/) diff --git a/google.geolocation/google.geolocation-tests.ts b/google.geolocation/google.geolocation-tests.ts new file mode 100644 index 00000000000000..f6574cfea461fd --- /dev/null +++ b/google.geolocation/google.geolocation-tests.ts @@ -0,0 +1,18 @@ +// Test files for Geolocation Definition file +/// + +//determine if the handset has client side geo location capabilities +var isInit: bool = geo_position_js.init(); +if(isInit){ + geo_position_js.getCurrentPosition(success_callback, error_callback); +} else { + alert("Functionality not available"); +} + +function success_callback(position: Position): void { + geo_position_js.showMap(position.coords.latitude, position.coords.longitude); +} + +function error_callback(positionError: PositionError): void { + console.log(positionError.code); +} \ No newline at end of file diff --git a/google.geolocation/google.geolocation.d.ts b/google.geolocation/google.geolocation.d.ts new file mode 100644 index 00000000000000..5260ba01e4df0b --- /dev/null +++ b/google.geolocation/google.geolocation.d.ts @@ -0,0 +1,12 @@ +// Type definitions for Google Geolocation 0.4.8 +// Project: https://code.google.com/p/geo-location-javascript/ +// Definitions by: Vincent Bortone +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface GeolocationStatic { + init(): bool; + getCurrentPosition(success: (position: Position) => void, error?: (positionError: PositionError) => void, opts?: PositionOptions): void; + showMap(latitude: number, longitude: number): void; +} + +declare var geo_position_js: GeolocationStatic; \ No newline at end of file