geo_coder.js.html 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>JSDoc: Source: services/geo_coder.js</title>
  6. <script src="scripts/prettify/prettify.js"> </script>
  7. <script src="scripts/prettify/lang-css.js"> </script>
  8. <!--[if lt IE 9]>
  9. <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  10. <![endif]-->
  11. <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
  12. <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
  13. </head>
  14. <body>
  15. <div id="main">
  16. <h1 class="page-title">Source: services/geo_coder.js</h1>
  17. <section>
  18. <article>
  19. <pre class="prettyprint source linenums"><code>/**
  20. * @ngdoc service
  21. * @name GeoCoder
  22. * @description
  23. * Provides [defered/promise API](https://docs.angularjs.org/api/ng/service/$q) service for Google Geocoder service
  24. */
  25. ngMap.service('GeoCoder', ['$q', function($q) {
  26. return {
  27. /**
  28. * @memberof GeoCoder
  29. * @param {Hash} options https://developers.google.com/maps/documentation/geocoding/#geocoding
  30. * @example
  31. * ```
  32. * GeoCoder.geocode({address: 'the cn tower'}).then(function(result) {
  33. * //... do something with result
  34. * });
  35. * ```
  36. * @returns {HttpPromise} Future object
  37. */
  38. geocode : function(options) {
  39. var deferred = $q.defer();
  40. var geocoder = new google.maps.Geocoder();
  41. geocoder.geocode(options, function (results, status) {
  42. if (status == google.maps.GeocoderStatus.OK) {
  43. deferred.resolve(results);
  44. } else {
  45. deferred.reject('Geocoder failed due to: '+ status);
  46. }
  47. });
  48. return deferred.promise;
  49. }
  50. }
  51. }]);
  52. </code></pre>
  53. </article>
  54. </section>
  55. </div>
  56. <nav>
  57. <h2><a href="index.html">Index</a></h2><h3>service</h3><ul><li><a href="Attr2Options.html">Attr2Options</a></li><li><a href="GeoCoder.html">GeoCoder</a></li><li><a href="NavigatorGeolocation.html">NavigatorGeolocation</a></li><li><a href="StreetView.html">StreetView</a></li></ul><h3>directive</h3><ul><li><a href="bicycling-layer.html">bicycling-layer</a></li><li><a href="cloud-layer.html">cloud-layer</a></li><li><a href="custom-control.html">custom-control</a></li><li><a href="drawing-manager.html">drawing-manager</a></li><li><a href="dynamic-maps-engine-layer.html">dynamic-maps-engine-layer</a></li><li><a href="fusion-tables-layer.html">fusion-tables-layer</a></li><li><a href="heatmap-layer.html">heatmap-layer</a></li><li><a href="info-window.html">info-window</a></li><li><a href="kml-layer.html">kml-layer</a></li><li><a href="lazy-load.html">lazy-load</a></li><li><a href="map.html">map</a></li><li><a href="map-data.html">map-data</a></li><li><a href="map-type.html">map-type</a></li><li><a href="MapController.html">MapController</a></li><li><a href="maps-engine-layer.html">maps-engine-layer</a></li><li><a href="marker.html">marker</a></li><li><a href="overlay-map-type.html">overlay-map-type</a></li><li><a href="shape.html">shape</a></li><li><a href="traffic-layer.html">traffic-layer</a></li><li><a href="transit-layer.html">transit-layer</a></li><li><a href="weather-layer.html">weather-layer</a></li></ul>
  58. </nav>
  59. <br clear="both">
  60. <footer>
  61. Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a>
  62. and <a href="https://github.com/allenhwkim/angular-jsdoc">angular-jsdoc</a>
  63. </footer>
  64. <script> prettyPrint(); </script>
  65. <script src="scripts/linenumber.js"> </script>
  66. <script>
  67. var href=window.location.href.match(/\/([^\/]+$)/)[1];
  68. document.querySelector("nav a[href='"+href+"']").scrollIntoView(true);
  69. if (window.location.hash == "")
  70. document.querySelector("body").scrollIntoView(true);
  71. </script>
  72. </body>
  73. </html>