1
1
define ( [
2
2
'../Core/BingMapsApi' ,
3
3
'../Core/buildModuleUrl' ,
4
- '../Core/Cartesian2' ,
5
4
'../Core/Check' ,
6
5
'../Core/Credit' ,
7
6
'../Core/defaultValue' ,
@@ -17,13 +16,11 @@ define([
17
16
'../Core/WebMercatorTilingScheme' ,
18
17
'../ThirdParty/when' ,
19
18
'./BingMapsStyle' ,
20
- './DiscardMissingTileImagePolicy' ,
21
19
'./DiscardEmptyTileImagePolicy' ,
22
20
'./ImageryProvider'
23
21
] , function (
24
22
BingMapsApi ,
25
23
buildModuleUrl ,
26
- Cartesian2 ,
27
24
Check ,
28
25
Credit ,
29
26
defaultValue ,
@@ -39,7 +36,6 @@ define([
39
36
WebMercatorTilingScheme ,
40
37
when ,
41
38
BingMapsStyle ,
42
- DiscardMissingTileImagePolicy ,
43
39
DiscardEmptyTilePolicy ,
44
40
ImageryProvider ) {
45
41
'use strict' ;
@@ -63,16 +59,9 @@ define([
63
59
* for information on the supported cultures.
64
60
* @param {Ellipsoid } [options.ellipsoid] The ellipsoid. If not specified, the WGS84 ellipsoid is used.
65
61
* @param {TileDiscardPolicy } [options.tileDiscardPolicy] The policy that determines if a tile
66
- * is invalid and should be discarded. The default value will depend on the map style. If
67
- * `BingMapsStyle.AERIAL_WITH_LABELS_ON_DEMAND` or `BingMapsStyle.ROADS_ON_DEMAND` is used, then a
68
- * {@link DiscardEmptyTileImagePolicy} will be used to handle the Bing Maps API sending no content instead of
69
- * a missing tile image, a behaviour specific to that imagery set. In all other cases, a default
70
- * {@link DiscardMissingTileImagePolicy} is used which requests tile 0,0 at the maximum tile level and checks
71
- * pixels (0,0), (120,140), (130,160), (200,50), and (200,200). If all of these pixels are transparent, the
72
- * discard check is disabled and no tiles are discarded. If any of them have a non-transparent color, any
73
- * tile that has the same values in these pixel locations is discarded. The end result of these defaults
74
- * should be correct tile discarding for a standard Bing Maps server. To ensure that no tiles are discarded,
75
- * construct and pass a {@link NeverTileDiscardPolicy} for this parameter.
62
+ * is invalid and should be discarded. By default, a {@link DiscardEmptyTileImagePolicy}
63
+ * will be used, with the expectation that the Bing Maps server will send a zero-length response for missing tiles.
64
+ * To ensure that no tiles are discarded, construct and pass a {@link NeverTileDiscardPolicy} for this parameter.
76
65
*
77
66
* @see ArcGisMapServerImageryProvider
78
67
* @see GoogleEarthEnterpriseMapsProvider
@@ -109,7 +98,12 @@ define([
109
98
this . _tileProtocol = options . tileProtocol ;
110
99
this . _mapStyle = defaultValue ( options . mapStyle , BingMapsStyle . AERIAL ) ;
111
100
this . _culture = defaultValue ( options . culture , '' ) ;
101
+
112
102
this . _tileDiscardPolicy = options . tileDiscardPolicy ;
103
+ if ( ! defined ( this . _tileDiscardPolicy ) ) {
104
+ this . _tileDiscardPolicy = new DiscardEmptyTilePolicy ( ) ;
105
+ }
106
+
113
107
this . _proxy = options . proxy ;
114
108
this . _credit = new Credit ( '<a href="http://www.bing.com"><img src="' + BingMapsImageryProvider . logoUrl + '" title="Bing Imagery"/></a>' ) ;
115
109
@@ -172,22 +166,6 @@ define([
172
166
173
167
that . _imageUrlTemplate = that . _imageUrlTemplate . replace ( / ^ h t t p : / , tileProtocol ) ;
174
168
175
- // Install the default tile discard policy if none has been supplied.
176
- if ( ! defined ( that . _tileDiscardPolicy ) ) {
177
- // Our default depends on which map style we're using.
178
- if ( that . _mapStyle === BingMapsStyle . AERIAL_WITH_LABELS_ON_DEMAND
179
- || that . _mapStyle === BingMapsStyle . ROAD_ON_DEMAND ) {
180
- // this map style uses a different API, which returns a tile with no data instead of a placeholder image
181
- that . _tileDiscardPolicy = new DiscardEmptyTilePolicy ( ) ;
182
- } else {
183
- that . _tileDiscardPolicy = new DiscardMissingTileImagePolicy ( {
184
- missingImageUrl : buildImageResource ( that , 0 , 0 , that . _maximumLevel ) . url ,
185
- pixelsToCheck : [ new Cartesian2 ( 0 , 0 ) , new Cartesian2 ( 120 , 140 ) , new Cartesian2 ( 130 , 160 ) , new Cartesian2 ( 200 , 50 ) , new Cartesian2 ( 200 , 200 ) ] ,
186
- disableCheckIfAllPixelsAreTransparent : true
187
- } ) ;
188
- }
189
- }
190
-
191
169
var attributionList = that . _attributionList = resource . imageryProviders ;
192
170
if ( ! attributionList ) {
193
171
attributionList = that . _attributionList = [ ] ;
@@ -547,11 +525,9 @@ define([
547
525
548
526
if ( defined ( promise ) ) {
549
527
return promise . otherwise ( function ( error ) {
550
-
551
- // One possible cause of an error here is that the image we tried to load was empty. This isn't actually
552
- // a problem. In some imagery sets (eg. `BingMapsStyle.AERIAL_WITH_LABELS_ON_DEMAND`), an empty image is
553
- // returned rather than a blank "This Image is Missing" placeholder image. In this case, we supress the
554
- // error.
528
+ // One cause of an error here is that the image we tried to load was zero-length.
529
+ // This isn't actually a problem, since it indicates that there is no tile.
530
+ // So, in that case we return the EMPTY_IMAGE sentinel value for later discarding.
555
531
if ( defined ( error . blob ) && error . blob . size === 0 ) {
556
532
return DiscardEmptyTilePolicy . EMPTY_IMAGE ;
557
533
}
@@ -680,6 +656,11 @@ define([
680
656
quadkey : BingMapsImageryProvider . tileXYToQuadKey ( x , y , level ) ,
681
657
subdomain : subdomains [ subdomainIndex ] ,
682
658
culture : imageryProvider . _culture
659
+ } ,
660
+ queryParameters : {
661
+ // this parameter tells the Bing servers to send a zero-length response
662
+ // instead of a placeholder image for missing tiles.
663
+ n : 'z'
683
664
}
684
665
} ) ;
685
666
}
0 commit comments