Ticket #2975 (closed feature: fixed)

Opened 3 years ago

Last modified 3 years ago

Bing layer with direct tile access

Reported by: ahocevar Owned by: euzuro
Priority: minor Milestone: 2.11 Release
Component: Layer Version: 2.10
Keywords: Cc:
State: Complete

Description

Bing now officially allows direct tile access. Let's use it! This ticket proposes a new layer type, Layer.Bing.

Attachments

openlayers-2975.patch Download (5.0 KB) - added by ahocevar 3 years ago.
proof of concept
openlayers-2975.2.patch Download (11.9 KB) - added by ahocevar 3 years ago.
uses JSONP, and adds required attribution
openlayers-2975.3.patch Download (15.7 KB) - added by ahocevar 3 years ago.
complete with unit tests
2975.patch Download (17.8 KB) - added by tschaub 3 years ago.
bing tiles
openlayers-2975.4.patch Download (17.8 KB) - added by ahocevar 3 years ago.
known set of resolutions

Change History

Changed 3 years ago by ahocevar

The above patch squeezes the new layer type into the Layer.XYZ file. I think it should go in a separate file. Also, for now, it requires a proxy. Maybe Microsoft provides a JSON callback, but I couldn't find anything about it.

Changed 3 years ago by ahocevar

Another TODO is that we need to set the attribution from the layer metadata, and fire the changelayer event so the Attribution control re-renders the attribution as soon as we get the metadata response.

Changed 3 years ago by ahocevar

proof of concept

Changed 3 years ago by ahocevar

Note: Adding a jsonp param to the metadata request will create a json callback. This is documented  here. The rest of the maps json api for getting imagery metadata is documented  here

Changed 3 years ago by ahocevar

uses JSONP, and adds required attribution

Changed 3 years ago by ahocevar

  • state set to Review

Example works and tests pass in IE6, IE7, IE8, FF3.6, Safari 5 and Opera 10. Thanks for any review.

Changed 3 years ago by ahocevar

complete with unit tests

Changed 3 years ago by tschaub

Thanks for the work on this. It will make a great addition to the layer collection.

I came across a few things in my review. There are likely better ways to handle these, but I've made changes in the patch that I'll describe below:

The OpenLayers.Layer.Bing.processMetadata function is called when the Bing script loads. In the previous patch, this calls initLayer, which relies on layer.resolutions being defined. Resolutions are initialized in layer.setMap. So, if the script loads before the layer is added to a map, layer.resolutions may not be defined. The tests weren't catching this because the only test that constructs a layer without adding it to a map overrides OpenLayers.Layer.Bing.processMetadata. I've modified the tests so the original processMetadata method is still called (after logging the metadata).

To make this updated test pass (and more importantly to make the layer work in applications where it is constructed but not added to a map for a while), I've added a initLayerAfterAdd method. If the layer is not added to a map by the time the Bing script loads, the initLayer method is not immediately called. Instead, initLayerAfterAdd is called when the layer is added to a map. This method unregisters itself (and destroy unregisters the same).

To support calling initLayerAfterAdd, I added an "added" even to the layer. This would be useful for all layers. Instead of extending this patch so it modifies Layer, I created #2983. When this ticket is closed, the "added" method should be moved from the Bing layer to the base Layer.

Finally, this is trivial, but I wasn't just being crass when I said that  xhtml is dead. The W3C officially stopped working on it in  July of 2009. As an effectively deprecated spec, I think we need to justify its use where it is required (nowhere that I know of). I updated the example to use HTML (and features of 5 where available).

Changed 3 years ago by tschaub

bing tiles

Changed 3 years ago by tschaub

  • state changed from Review to Commit

One more change that I hope you'll consider. I made it so the layer property that determines the tile type is named "type" instead of "layer". This will bring the Bing layer closer in line with the Google layer. It also will avoid confusion where a record of layer properties is kept (layer.layer is less intuitive than layer.type in my opinion).

The Bing and XYZ tests still pass with these changes, and examples still work.

Thanks for the excellent work on this. Please commit if you agree with the above changes.

PS - I think we can improve things to avoid pink tiles in certain cases, but that can be handled at the application level for now and I think this change should get in asap.

Changed 3 years ago by ahocevar

known set of resolutions

Changed 3 years ago by ahocevar

Thanks for the review and the hard work to improve this. I agree with all your changes, except for initLayerAfterAdd. Instead, I gave the layer a fixed set of resolutions in a constant, so resolutions are always available for initLayer. This should also help to avoid pink tile issues.

Changed 3 years ago by ahocevar

Changed 3 years ago by ahocevar

  • status changed from new to closed
  • state changed from Commit to Complete
  • resolution set to fixed
Note: See TracTickets for help on using tickets.