@@ -51,6 +51,8 @@ ol.Feature.prototype.playBouncing = function (_map, layerGroup) {
51
51
let listenerKey ;
52
52
53
53
//Direção do marcador
54
+ //para cima os valores são negativos
55
+ //para baixo os valores são positivos
54
56
let way = { up : 1 , down : - 1 } ;
55
57
56
58
//Momento em que a animação começou
@@ -95,6 +97,7 @@ ol.Feature.prototype.playBouncing = function (_map, layerGroup) {
95
97
96
98
listenerKey = _map . on ( 'postcompose' , Animate , { feature : this , map : _map } ) ;
97
99
100
+
98
101
}
99
102
100
103
//Função responsável por executar a animação quadro a quadro
@@ -143,7 +146,17 @@ ol.Feature.prototype.playBouncing = function (_map, layerGroup) {
143
146
else
144
147
{
145
148
//Atualiza a posição do marcador com a nova posição
146
- this . feature . getGeometry ( ) . setCoordinates ( [ position [ 0 ] , position [ 1 ] , 0 ] ) ;
149
+ //verifica se a posição atual é maior do que a última atinginda
150
+ if ( this . feature . upMax != undefined && position [ 1 ] > this . feature . upMax )
151
+ {
152
+ //caso a nova posição ultrapasse os limites a última posição máxima é atribuída
153
+ this . feature . getGeometry ( ) . setCoordinates ( [ position [ 0 ] , this . feature . upMax , 0 ] ) ;
154
+ }
155
+ else
156
+ {
157
+ this . feature . getGeometry ( ) . setCoordinates ( [ position [ 0 ] , position [ 1 ] , 0 ] ) ;
158
+ }
159
+
147
160
}
148
161
}
149
162
@@ -162,7 +175,7 @@ ol.Feature.prototype.playBouncing = function (_map, layerGroup) {
162
175
163
176
var styleb = new ol . style . Style ( {
164
177
image : new ol . style . Circle ( {
165
- radius : radius_b ,
178
+ radius : Math . abs ( radius_b ) ,
166
179
snapToPixel : false ,
167
180
stroke : new ol . style . Stroke ( {
168
181
color : 'rgba(255, 0, 0, ' + opacity_b + ')' ,
@@ -173,7 +186,7 @@ ol.Feature.prototype.playBouncing = function (_map, layerGroup) {
173
186
174
187
var stylec = new ol . style . Style ( {
175
188
image : new ol . style . Circle ( {
176
- radius : radius_c ,
189
+ radius : Math . abs ( radius_c ) ,
177
190
snapToPixel : false ,
178
191
stroke : new ol . style . Stroke ( {
179
192
color : 'rgba(255, 0, 0, ' + opacity_c + ')' ,
@@ -184,7 +197,7 @@ ol.Feature.prototype.playBouncing = function (_map, layerGroup) {
184
197
185
198
var style = new ol . style . Style ( {
186
199
image : new ol . style . Circle ( {
187
- radius : radius_a ,
200
+ radius : Math . abs ( radius_a ) ,
188
201
snapToPixel : false ,
189
202
stroke : new ol . style . Stroke ( {
190
203
color : 'rgba(255, 0, 0, ' + opacity_a + ')' ,
@@ -221,8 +234,11 @@ ol.Feature.prototype.playBouncing = function (_map, layerGroup) {
221
234
ol . Observable . unByKey ( listenerKey ) ;
222
235
223
236
//Caso a animação esteja no estado parado a animação não irá ocorrer novamente e o marcador volta para a posição inicial
237
+ this . map . render ( ) ;
238
+
224
239
if ( this . feature . _stopBouncing )
225
240
{
241
+
226
242
this . feature . getGeometry ( ) . setCoordinates ( this . feature . position . getCoordinates ( ) , false ) ;
227
243
return ;
228
244
}
@@ -233,6 +249,10 @@ ol.Feature.prototype.playBouncing = function (_map, layerGroup) {
233
249
234
250
restart = false ;
235
251
252
+ //atualiza com a última posição máxima atingida
253
+ if ( this . feature . upMax == undefined && this . feature . direction == way . up )
254
+ this . feature . upMax = position [ 1 ] ;
255
+
236
256
this . feature . direction = this . feature . direction * way . down ;
237
257
238
258
//Solicita uma nova animação e adiciona a referência novamente para o listener
0 commit comments