Skip to content
This repository was archived by the owner on Apr 19, 2026. It is now read-only.

Commit 2e10936

Browse files
author
Yvonne Yip
committed
add google map places search
1 parent 9b410dc commit 2e10936

3 files changed

Lines changed: 35 additions & 2 deletions

File tree

google-map-search.html

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<link rel="import" href="../polymer/polymer.html">
2+
3+
<polymer-element name="google-map-search" attributes="query result map">
4+
<script>
5+
Polymer('google-map-search', {
6+
result: {
7+
latitude: '37.77493',
8+
longitude: '-122.41942',
9+
show: false
10+
},
11+
search: function() {
12+
var places = new google.maps.places.PlacesService(this.map);
13+
places.textSearch({query: this.query}, this.gotResults.bind(this));
14+
},
15+
gotResults: function(results, status) {
16+
this.result = {
17+
latitude: results[0].geometry.location.lat(),
18+
longitude: results[0].geometry.location.lng(),
19+
show: true
20+
}
21+
}
22+
});
23+
</script>
24+
</polymer-element>

google-map.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<script>
2727
(function() {
2828
var CALLBACK_NAME = 'polymer_google_map_callback';
29-
var MAP_URL = 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&callback=' + CALLBACK_NAME;
29+
var MAP_URL = 'https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places&sensor=false&callback=' + CALLBACK_NAME;
3030
var pendingCallbacks = [];
3131
var loading;
3232

metadata.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,13 @@
1616
<template id="imports">
1717
<link rel="import" href="google-map-directions.html">
1818
</template>
19-
</x-meta>
19+
</x-meta>
20+
21+
<x-meta id="google-map-search" label="Google Map Search">
22+
<template>
23+
<google-map-search></google-map-search>
24+
</template>
25+
<template id="imports">
26+
<link rel="import" href="google-map-search.html">
27+
</template>
28+
</x-meta>

0 commit comments

Comments
 (0)