Ticket #2328 (closed bug: fixed)

Opened 4 years ago

Last modified 3 years ago

Google termsOfUse are visible on all Layers on startup

Reported by: mar_rud Owned by: elemoine
Priority: minor Milestone: 2.9 Release
Component: Layer.Google Version: 2.8
Keywords: Cc:
State: Complete

Description

When adding Google layer, its termOfUse div gets somehow displayed (style.display from 'none' to ) after creating map and it is visible even when different layer is selected. You can see this i.e. here:

http://openlayers.org/dev/examples/spherical-mercator.html

When changing to OSM, Google's termsOfUse are still visible. In fact You need to cycle through all google layers to make sure all termsOfUse divs have again proper display value and are visible only on Layer they belong to.

I debuged it a little on my page:
 http://mapa.ump.waw.pl/ump-www/index_en.html[[BR]] Its style.display is correct when exiting onload initialization function, it gets displayed while rendering map. Google.display(display) is not the source, it is called only once per google layer with proper false parameter.

As a dirty solution I can add:

this.termsOfUse.style.visibility=display?"":"hidden";

to Google.display(display) function, and at least it isn't visible when not needed, but it shouldn't get displayed in first place while rendering map. Is it google API cycling throw all divs and enabling its own?

Attachments

patch-2328-r9930-A0.diff Download (2.0 KB) - added by elemoine 3 years ago.
patch-2328-r-9936-A0.diff Download (2.2 KB) - added by fredj 3 years ago.
set the this.termsOfUse size to 0
2328.3.patch Download (1.3 KB) - added by fredj 3 years ago.
set div visibility instead of display. Solution by mar_rud. He was right from the beginning :-). Works with FF, chrome and IE8
2328.4.patch Download (1.1 KB) - added by fredj 3 years ago.
unit test to demonstrate the issue
openlayers-2328.patch Download (2.7 KB) - added by ahocevar 3 years ago.
use additional negative offset to hide termsOfUse
openlayers-2328-reopened.patch Download (2.8 KB) - added by ahocevar 3 years ago.
special treatment for allOverlays: true

Change History

  Changed 3 years ago by asaunier

When examining the http://openlayers.org/dev/examples/spherical-mercator.html HTML code in Firebug, one can notice that all 3 "olLayerGoogleCopyright" divs are visible at start up whereas the "powered by" logo divs are not ("display:none" in element style) except the one of the current GM layer. It seems that a "display:none" attribute is missing for the "olLayerGoogleCopyright" divs of not visible GM layers.

This behaviour difference is weird because termsOfUse and poweredBy properties are handled by exactly the same code in OpenLayers.Layer.Google. In addition the CSS styles are consistent.

Could it be a problem coming from the Google Maps API itself ?

Changed 3 years ago by elemoine

  Changed 3 years ago by elemoine

  • owner changed from euzuro to elemoine

patch-2328-r9930-A0.diff Download fixes the problem (at least in FF3). I'll give more explanations on the patch in a later comment.

  Changed 3 years ago by fredj

It's probably the GAddCopyright() fault.

The patch also works in chrome.

  Changed 3 years ago by fredj

also found that setting the display in loadMapObject is not needed: display is called just after for every layers. patch to come.

  Changed 3 years ago by fredj

the patch breaks the navigation control, to reproduce apply the patch and load examples/google.html -> can't zoom with mousewheel because the "terms of use" div uses all the space.

i'll try to prepare a new version (set the width and height to 0).

Changed 3 years ago by fredj

set the this.termsOfUse size to 0

  Changed 3 years ago by fredj

  • state set to Review

please review (tested only with FF3 and chrome)

  Changed 3 years ago by asaunier

The patch seems to work in my application.

However I wanted to report a strange behaviour I have noticed during the first reloads of my app: the "Map data c2009 Tele Atlas" was sometimes missing before the "Terms of use" link in my default "Google Physical" layer, depending on the screen size. But I can no more reproduce the problem and it's all right now (maybe a cache problem).

follow-up: ↓ 9   Changed 3 years ago by mar_rud

I have reported bug mostly in form of FYI, because I use my solution suggested in the beginning for 2 months and don't have any problem reports from users:  http://mapa.ump.waw.pl/ump-www/ I even forget about this bug report.

I have some doubts about changing size to 0,0, as I have bad experience with IE, especially ie6. It sometimes ignores height and line-height:0 is also needed. Not sure, but also changing size to 0,0 can sometimes be not enough without overflow:hidden? I don't have ie in range to check.

My fix, in its semantic meaning, hides content (visibility:hidden), instead of shrinking it to 0 size.

But if You check it on all browsers, and it works as expected without side effects, I don't care how it is repaired.

in reply to: ↑ 8   Changed 3 years ago by asaunier

Replying to mar_rud:

I have some doubts about changing size to 0,0, as I have bad experience with IE, especially ie6.

I'm afraid you're right: it seems the patch doesn't work with IE7 and IE8.

Changed 3 years ago by fredj

set div visibility instead of display. Solution by mar_rud. He was right from the beginning :-). Works with FF, chrome and IE8

follow-up: ↓ 11   Changed 3 years ago by asaunier

Tim Schaub recently commited changes in OpenLayers.Layer.Google:  http://trac.openlayers.org/changeset/10021

The changes obviously create conflicts with patches listed above but it seems that they fix the problem anyway, at least with FF. Maybe there are still troubles with IE: [2466]

in reply to: ↑ 10   Changed 3 years ago by asaunier

Replying to asaunier:

Maybe there are still troubles with IE: [2466]

I meant #2466

  Changed 3 years ago by ahocevar

  • status changed from new to closed
  • state changed from Review to Complete
  • resolution set to fixed

Should be fixed now [10021]. If you still encounter issues, please reopen this ticket or create a new one describing the problem.

  Changed 3 years ago by fredj

  • status changed from closed to reopened
  • state Complete deleted
  • resolution fixed deleted

the termsOfUse element is still visible on startup if the Google is not the base layer:

var map = new OpenLayers.Map('map');
var gmap = new OpenLayers.Layer.Google("Google Streets");
var osm = new OpenLayers.Layer.OSM("OSM");
map.addLayers([osm, gmap]);
map.zoomToMaxExtent();

Changed 3 years ago by fredj

unit test to demonstrate the issue

Changed 3 years ago by ahocevar

use additional negative offset to hide termsOfUse

  Changed 3 years ago by ahocevar

  • state set to Review

The above patch does not set style.visibility, but sets a negative offset on style.left. I like this better than style.visibility, because this way the element does not take the space at its position, making sure that events go through appropriately.

I added unit tests (based on fredj's patch). Tests still pass, and  http://dev.openlayers.org/tests/manual/google-resize.html does not show TermsOfUse any more after loading.

Thanks for any review.

  Changed 3 years ago by fredj

  • state changed from Review to Commit

works on FF3.6 and IE7, thanks Andreas.

  Changed 3 years ago by ahocevar

  • status changed from reopened to closed
  • state changed from Commit to Complete
  • resolution set to fixed

(In [10069]) hide Terms Of Use for invisible Google Layers using a negative offset, because during GMap2 initialization, we don't have control over style.display. r=fredj (closes #2328)

Changed 3 years ago by ahocevar

special treatment for allOverlays: true

  Changed 3 years ago by ahocevar

  • status changed from closed to reopened
  • state changed from Complete to Review
  • resolution fixed deleted

If the map is configured with allOverlays: true, setVisibilty is not called. So when the layer is configured with visibility: false, the Terms Of Use and Logo are visible.

The attached patch has a testcase which shows the issue, and a fix. Please review.

  Changed 3 years ago by pgiraud

  • state changed from Review to Commit

2 things :

  • I don't think that setting isBaseLayer to true when the map is given allOverlays options the true value has any effect,
  • there's a typo (allOvarlays).

This said, you can commit.

  Changed 3 years ago by ahocevar

  • status changed from reopened to closed
  • state changed from Commit to Complete
  • resolution set to fixed

(In [10079]) fixed visibility issue with allOverlays:true. r=pgiraud (closes #2328)

Note: See TracTickets for help on using tickets.