/
paper-contact-address.html
73 lines (58 loc) · 1.71 KB
/
paper-contact-address.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!doctype html>
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-icon/iron-icon.html">
<link rel="import" href="../iron-icons/maps-icons.html">
<link rel="import" href="../paper-item/paper-icon-item.html">
<link rel="import" href="../paper-item/paper-item-body.html">
<link rel="import" href="../paper-ripple/paper-ripple.html">
<link rel="import" href="paper-contact-behavior.html">
<link rel="import" href="paper-contact-shared-styles.html">
<!--
Component for address contact details, that triggers the opening of Google Maps to the specified address on tap.
### Example
```html
<paper-contact-address latitude="51.5287718" longitude="-0.2416798">
London
</paper-contact-address>
```
@demo demo/index.html
-->
<dom-module id="paper-contact-address">
<template>
<style include="paper-contact-shared-styles"></style>
<paper-icon-item class="item" on-tap="openInBlankTab">
<paper-ripple></paper-ripple>
<iron-icon class="icon" icon="maps:place" slot="item-icon"></iron-icon>
<div class="text"><slot></slot></div>
</paper-icon-item>
</template>
</dom-module>
<script>
(function() {
Polymer({
is: 'paper-contact-address',
properties: {
/**
* Latitude of the desired location, e.g. 51.5287718
*/
latitude: Number,
/**
* Longitude of the desired location, e.g. -0.2416798
*/
longitude: Number
},
behaviors: [
Polymer.PaperContactBehavior
],
// Private methods
_getTargetUrl: function(content) {
let url = `https://www.google.com/maps/search/${content}`;
// Only add coordinates if they are known
if (this.latitude && this.longitude) {
url += `/@${this.latitude}+${this.longitude}`;
}
return url;
}
});
})();
</script>