Skip to content

Commit

Permalink
add google map places search
Browse files Browse the repository at this point in the history
  • Loading branch information
Yvonne Yip committed Jan 10, 2014
1 parent 9b410dc commit 2e10936
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
24 changes: 24 additions & 0 deletions google-map-search.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<link rel="import" href="../polymer/polymer.html">

<polymer-element name="google-map-search" attributes="query result map">
<script>
Polymer('google-map-search', {
result: {
latitude: '37.77493',
longitude: '-122.41942',
show: false
},
search: function() {
var places = new google.maps.places.PlacesService(this.map);
places.textSearch({query: this.query}, this.gotResults.bind(this));
},
gotResults: function(results, status) {
this.result = {
latitude: results[0].geometry.location.lat(),
longitude: results[0].geometry.location.lng(),
show: true
}
}
});
</script>
</polymer-element>
2 changes: 1 addition & 1 deletion google-map.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<script>
(function() {
var CALLBACK_NAME = 'polymer_google_map_callback';
var MAP_URL = 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&callback=' + CALLBACK_NAME;
var MAP_URL = 'https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places&sensor=false&callback=' + CALLBACK_NAME;
var pendingCallbacks = [];
var loading;

Expand Down
11 changes: 10 additions & 1 deletion metadata.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,13 @@
<template id="imports">
<link rel="import" href="google-map-directions.html">
</template>
</x-meta>
</x-meta>

<x-meta id="google-map-search" label="Google Map Search">
<template>
<google-map-search></google-map-search>
</template>
<template id="imports">
<link rel="import" href="google-map-search.html">
</template>
</x-meta>

0 comments on commit 2e10936

Please sign in to comment.