UNPKG

gaf-mobile

Version:

GAF mobile Web site

114 lines (103 loc) 5.01 kB
<!DOCTYPE html> <html lang="en" ng-app="example"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Injecting Custom Place Predictions</title> <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> <link rel="stylesheet" href="../src/autocomplete.css"> <!-- Required dependencies --> <script src="https://maps.googleapis.com/maps/api/js?libraries=places"></script> <script src="lib/angular/angular.js"></script> <!-- Google Places Autocomplete directive --> <script src="../src/autocomplete.js"></script> <script> angular.module('example', ['google.places']) // Setup a basic controller with a scope variable 'place' .controller('MainCtrl', function ($scope) { $scope.place = null; $scope.myPlaces = [ buildGooglePlacesResult({ address: { street: 'International Airport - T1', suburb: 'Sydney', state: 'NSW' }, location: { latitude: -33.936722, longitude: 151.164266 } }), buildGooglePlacesResult({ address: { street: 'Domestic Airport - T2', suburb: 'Sydney', state: 'NSW' }, location: { latitude: -33.933617, longitude: 151.181630 } }), buildGooglePlacesResult({ address: { street: 'Domestic Airport - T3', suburb: 'Sydney', state: 'NSW' }, location: { latitude: -33.933076, longitude: 151.181270 } }) ]; function buildGooglePlacesResult(config) { // Build a synthetic google.maps.places.PlaceResult object return { formatted_address: config.address.street + ', ' + config.address.suburb + ', ' + config.address.state, address_components: [ { long_name: config.address.street, short_name : config.address.street, types: [ 'route' ] }, { long_name: config.address.suburb, short_name: config.address.suburb, types: [ 'locality' ] }, { long_name: config.address.state, short_name: config.address.state, types: [ 'administrative_area_level_1' ] } ], geometry: { location: { lat: function () { return config.location.latitude }, lng: function () { return config.location.longitude } } } }; } }); </script> </head> <body ng-controller="MainCtrl"> <div class="container"> <div class="row"> <div class="col-md-12"> <h1>Injecting Custom Place Predictions</h1> <p> Three custom results are injected into the Place Predictions. Try searching for "International Airport" or "Domestic Airport" to see them in action. </p> <p class="alert alert-info"> <i class="glyphicon glyphicon-info-sign"></i> Custom places appear with a label after them as required by the <a href="https://developers.google.com/maps/terms">Google Places API terms</a>. This label can be overridden by putting a <code>custom_prediction_label</code> on your custom place results. The label can also be styled via the <code>.custom-prediction-label</code> class. </p> <form class="form"> <input class="form-control" g-places-autocomplete custom-places="myPlaces" ng-model="place"/> </form> <h5>Result:</h5> <pre>{{place | json}}</pre> </div> </div> </div> </body> </html>