This repository has been archived by the owner on Jul 9, 2024. It is now read-only.
forked from DimShadoWWW/eco-json-schema-form
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eco-json-schema-geolocation.html
165 lines (143 loc) · 4.43 KB
/
eco-json-schema-geolocation.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<link rel="import" href="../polymer/polymer.html" />
<link rel="import" href="../iron-flex-layout/iron-flex-layout.html" />
<link rel="import" href="../app-localize-behavior/app-localize-behavior.html">
<!--
`eco-json-schema-geolocation` takes in a JSON schema of type number and string and
contains a `paper-geolocation`, exposing a `value` property that represents the schema.
Validation is handled for strings and number/integers by mapping JSON schema
validation keywords to `paper-geolocation` attributes; form elements will automatically
try and validate themselves as users provide input:
Please see the `eco-json-schema-object` documentation for further information.
@group eco Elements
@element eco-json-schema-geolocation
@demo demo/index.html
-->
<dom-module id="eco-json-schema-geolocation">
<link rel="import" href="../iron-icons/iron-icons.html">
<link rel="import" href="../iron-icons/communication-icons.html">
<link rel="import" href="../paper-input/paper-input.html" />
<link rel="import" href="../paper-input/paper-input-container.html">
<link rel="import" href="../paper-input/paper-input-error.html">
<link rel="import" href="../paper-styles/typography.html" />
<link rel="import" href="../geo-location/geo-location.html" />
<link rel="import" href="../google-map/google-map.html" />
<link rel="import" href="../google-map/google-map-marker.html">
<template>
<style is="custom-style" include="iron-flex-layout">
:host {
display: block;
overflow: hidden
}
:host google-map {
height: 16em;
width: 16em;
border: none
}
paper-input {
padding: 2px;
--paper-input-container-label: {
white-space: normal;
position: static;
font-size: 22px;
color: #212121;
}
}
</style>
<!--<geo-location watch-pos-->
<geo-location high-accuracy latitude="{{latitude}}" longitude="{{longitude}}" on-geo-error="geoError">
</geo-location>
<!-- information text above the map -->
<template is="dom-if" if="{{!latitude}}">
{{localize('location-unknown')}}
</template>
<template is="dom-if" if="{{latitude}}">
<paper-material elevation="0" class="layout">
<paper-material elevation="0" class="layout">
latitud: <span>{{latitude}}</span>, longitud: <span>{{longitude}}</span>
<!--,{{localize('accuracy')}}: <span>{{accuracy}}</span>m-->
</paper-material>
</paper-material>
</template>
<div>
<google-map id="map2" longitude="[[longitude]]" latitude="[[latitude]]" zoom="15">
<google-map-marker longitude="{{longitude}}" latitude="{{latitude}}" draggable="true"></google-map-marker>
</google-map>
</div>
<template is="dom-if" if="[[errorMessage]]">
<paper-input-error aria-live="assertive">[[errorMessage]]</paper-input-error>
</template>
</template>
<script>
Polymer({
is: 'eco-json-schema-geolocation',
behaviors: [
Polymer.AppLocalizeBehavior
],
properties: {
language: {
value: 'es'
},
resources: {
type: Object,
notify: true
},
schema: {
type: Object,
observer: '_schemaChanged'
},
value: {
type: Object,
notify: true,
computed: '_geoLocationComp(latitude,longitude)'
},
error: {
type: String,
observer: '_errorChanged',
value: null
},
latitude: {
type: Number,
//observer: '_geoChange',
notify: true,
value: 1
},
longitude: {
type: Number,
//observer: '_geoChange',
notify: true,
value: 1
},
zoom: {
type: Number,
notify: true
}
},
ready: function () {
this.set('latitude', 0);
this.set('longitude', 0);
//this._geoLocationComp(this.latitude,this.longitude);
},
_schemaChanged: function () {
var schema = this.schema;
},
_errorChanged: function() {
if (this.error) {
this.errorMessage = this.error;
} else {
this.errorMessage = null;
}
},
geoError: function (event) {
var error = event.detail;
console.error(error);
this.error = JSON.stringify(error);
},
_geoLocationComp: function(latitude,longitude){
return {
'latitude': latitude,
'longitude': longitude
};
}
});
</script>
</dom-module>