Commit 8247bfb1d78dd67ea6ef33d816dc10fb8fc21f21
1 parent
76e1af60
improved polygon tooltip auto close
Showing
2 changed files
with
14 additions
and
3 deletions
@@ -338,15 +338,21 @@ export default class TbGoogleMap { | @@ -338,15 +338,21 @@ export default class TbGoogleMap { | ||
338 | locationSettings: settings, | 338 | locationSettings: settings, |
339 | dsIndex: location.dsIndex | 339 | dsIndex: location.dsIndex |
340 | }); | 340 | }); |
341 | - | 341 | + let map = this; |
342 | if (onClickListener) { | 342 | if (onClickListener) { |
343 | google.maps.event.addListener(polygon, 'click', function (event) { | 343 | google.maps.event.addListener(polygon, 'click', function (event) { |
344 | - if (settings.displayTooltip) { | 344 | + if (settings.displayTooltip ) { |
345 | + if (settings.autocloseTooltip) { | ||
346 | + map.tooltips.forEach((tooltip) => { | ||
347 | + tooltip.popup.close(); | ||
348 | + }); | ||
349 | + } | ||
345 | if (!polygon.anchor) { | 350 | if (!polygon.anchor) { |
346 | polygon.anchor = new google.maps.MVCObject(); | 351 | polygon.anchor = new google.maps.MVCObject(); |
347 | } | 352 | } |
348 | polygon.anchor.set("position", event.latLng); | 353 | polygon.anchor.set("position", event.latLng); |
349 | popup.open(this.map, polygon.anchor); | 354 | popup.open(this.map, polygon.anchor); |
355 | + | ||
350 | } | 356 | } |
351 | onClickListener(); | 357 | onClickListener(); |
352 | }); | 358 | }); |
@@ -287,7 +287,7 @@ export default class TbTencentMap { | @@ -287,7 +287,7 @@ export default class TbTencentMap { | ||
287 | popup.open(); | 287 | popup.open(); |
288 | popup.setPosition(marker); | 288 | popup.setPosition(marker); |
289 | }); | 289 | }); |
290 | - this.tooltips.push({ | 290 | + map.tooltips.push({ |
291 | markerArgs: markerArgs, | 291 | markerArgs: markerArgs, |
292 | popup: popup, | 292 | popup: popup, |
293 | locationSettings: settings, | 293 | locationSettings: settings, |
@@ -353,6 +353,11 @@ export default class TbTencentMap { | @@ -353,6 +353,11 @@ export default class TbTencentMap { | ||
353 | 353 | ||
354 | if (onClickListener) { | 354 | if (onClickListener) { |
355 | qq.maps.event.addListener(polygon, 'click', function (event) { | 355 | qq.maps.event.addListener(polygon, 'click', function (event) { |
356 | + if (settings.autocloseTooltip) { | ||
357 | + map.tooltips.forEach((tooltip) => { | ||
358 | + tooltip.popup.close(); | ||
359 | + }); | ||
360 | + } | ||
356 | if (settings.displayTooltip) { | 361 | if (settings.displayTooltip) { |
357 | popup.setMap(this.map); | 362 | popup.setMap(this.map); |
358 | popup.setPosition(event.latLng); | 363 | popup.setPosition(event.latLng); |