[OpenLayers-Users] Disappear layers with large scale google maps

Ishikawa Hiroshi ishikawa at geowork.co.jp
Wed Feb 14 22:51:59 EST 2007


Thanks for everyone.

I could succeed display layers with the largest scale of googlemaps.

I feel this is a quite simple problem.
I'm wondering that the problem is the value of "MAX_ZOOM_LEVEL" and "RESOLUTIONS" in the Google.js.

I chenged the valuse of "MAX_ZOOM_LEVEL" to 20 and added three small scales to
RESOLUTIONS.

Now my RESOLUTIONS is
RESOLUTIONS:[1.40625,0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.001373291015625,0.0006866455078125,0.00034332275390625,0.000171661376953125,0.0000858306884765625,0.00004291534423828125,0.0000214576721191140625,0.000107288360595703125,0.0000053644182978515625,0.000002682209014892578125],

As a resulet I can see more zoomed maps on the openlayers.
When we use Google Satellite we mightn't notice.
But with a normal map we could recognize the difference.

best wish,

Ishikawa Hiroshi

On Thu, 15 Feb 2007 05:00:50 +0900, Arnd Wippermann <arnd.wippermann at web.de> wrote:

> Hello,
>
> The solution, which I'm using for displaying all zoomlevels for Google and the WMS, is something i have found in the mailing list for OpenLayers Dev (http://www.nabble.com/Google-Zoom-Levels-tf2644005.html) and is from Ludwig Max Brinckmann.
>
> Put this in your html
>
> <script type="text/javascript" src="OpenLayers2.2.js"></script>
> <!-- Overwrite the original class -->
> <script type="text/javascript" src="Google_ludwig.js"></script>
>
> <script>
>
> ...
> //somthing like this
> map = new OpenLayers.Map('map', {maxExtent: new OpenLayers.Bounds(myBounds[0], myBounds[1], myBounds[2], myBounds[3]), maxResolution: mymaxResolution, projection: mySRS, maxZoomLevel: mymaxZoomLevel, controls:[],'numZoomLevels':22 } );
>
> //and this
> googleLyr = new OpenLayers.Layer.Google( "Google Satellite" , {type: G_SATELLITE_MAP, 'maxZoomLevel':22} );
>
> ...
>
> </script>
>
> And save this as Google_ludwig.js
>
> /*#################################################
> Google_ludwig.js
> #################################################*/
>
> OpenLayers.Layer.Google=OpenLayers.Class.create();
> OpenLayers.Layer.Google.prototype=
>   OpenLayers.Class.inherit(OpenLayers.Layer.EventPane,
>                            OpenLayers.Layer.FixedZoomLevels,
>   {
>     MIN_ZOOM_LEVEL:0,
>     MAX_ZOOM_LEVEL:22,
>     RESOLUTIONS:[1.40625,0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.001373291015625,0.0006866455078125,0.00034332275390625,0.000171661376953125,0.0000858306884765625,0.00004291534423828125,0.0000214576721191140625,0.000107288360595703125,0.0000053644182978515625,0.000002682209014892578125,0.0000013411045074462890625,0.00000067055225372314453125],
>
>     type:null,
>
>     initialize:function(name,options){
>         OpenLayers.Layer.EventPane.prototype.initialize.apply(this,arguments);
>         OpenLayers.Layer.FixedZoomLevels.prototype.initialize.apply(this,arguments);
>         this.addContainerPxFunction();
>     },
>
>     loadMapObject:function(){
>         try{
>             this.mapObject=new GMap2(this.div);
>             var poweredBy=this.div.lastChild;
>             this.div.removeChild(poweredBy);
>             this.pane.appendChild(poweredBy);
>             poweredBy.className="olLayerGooglePoweredBy gmnoprint";
>             poweredBy.style.left="";
>             poweredBy.style.bottom="";
>             var termsOfUse=this.div.lastChild;
>             this.div.removeChild(termsOfUse);
>             this.pane.appendChild(termsOfUse);
>             termsOfUse.className="olLayerGoogleCopyright";
>             termsOfUse.style.right="";
>             termsOfUse.style.bottom="";
>         }catch(e){
>             }
>     },
>
>     setMap:function(map){
>         OpenLayers.Layer.EventPane.prototype.setMap.apply(this,arguments);
>         if(this.type!=null){
>             this.map.events.register("moveend",this,this.setMapType);
>         }
>     },
>
>     setMapType:function(){if(this.mapObject.getCenter()!=null){this.mapObject.setMapType(this.type);
>     this.map.events.unregister("moveend",this,this.setMapType);
>     }},
>
>     onMapResize:function(){
>         this.mapObject.checkResize();
>     },
>
>     getOLBoundsFromMapObjectBounds:function(moBounds){
>         var olBounds=null;
>         if(moBounds!=null){
>             var sw=moBounds.getSouthWest();
>             var ne=moBounds.getNorthEast();
>             olBounds=new OpenLayers.Bounds(sw.lng(),sw.lat(),ne.lng(),ne.lat());
>         }
>         return olBounds;
>     },
>
>     getMapObjectBoundsFromOLBounds:function(olBounds){
>         var moBounds=null;
>         if(olBounds!=null){
>             var sw=new GLatLng(olBounds.bottom,olBounds.left);
>             var ne=new GLatLng(olBounds.top,olBounds.right);
>             moBounds=new GLatLngBounds(sw,ne);
>         }
>         return moBounds;
>     },
>
>     addContainerPxFunction:function(){
>         if(typeof GMap2!="undefined"&&!GMap2.fromLatLngToContainerPixel)
>         {
>             GMap2.prototype.fromLatLngToContainerPixel=function(gLatLng)
>             {
>                 var gPoint=this.fromLatLngToDivPixel(gLatLng);
>                 var div=this.b.firstChild.firstChild;
>                 gPoint.x+=div.offsetLeft;
>                 gPoint.y+=div.offsetTop;
>                 return gPoint;
>             };
>         }
>     },
>
>     getWarningHTML:function()
>     {
>         var html="";
>         html+="The Google Layer was unable to load correctly.<br>";
>         html+="<br>";
>         html+="To get rid of this message, select a new BaseLayer "
>         html+="in the layer switcher in the upper-right corner.<br>";
>         html+="<br>";
>         html+="Most likely, this is because the Google Maps library";
>         html+=" script was either not included, or does not contain the";
>         html+=" correct API key for your site.<br>";
>         html+="<br>";
>         html+="Developers: For help getting this working correctly, ";
>         html+="<a href='http://trac.openlayers.org/wiki/Google' "
>         html+="target='_blank'>";
>         html+="click here";
>         html+="</a>";
>         return html;
>     },
>
>     setMapObjectCenter:function(center,zoom){this.mapObject.setCenter(center,zoom);
>     },
>
>     getMapObjectCenter:function(){return this.mapObject.getCenter();
>     },
>
>     getMapObjectZoom:function(){return this.mapObject.getZoom();
>     },
>
>     getMapObjectLonLatFromMapObjectPixel:function(moPixel){return this.mapObject.fromContainerPixelToLatLng(moPixel);
>     },
>
>     getMapObjectPixelFromMapObjectLonLat:function(moLonLat){return this.mapObject.fromLatLngToContainerPixel(moLonLat);
>     },
>
>     getMapObjectZoomFromMapObjectBounds:function(moBounds){return this.mapObject.getBoundsZoomLevel(moBounds);
>     },
>
>     getLongitudeFromMapObjectLonLat:function(moLonLat){return moLonLat.lng();
>     },
>
>     getLatitudeFromMapObjectLonLat:function(moLonLat){return moLonLat.lat();
>     },
>
>     getMapObjectLonLatFromLonLat:function(lon,lat){return new GLatLng(lat,lon);
>     },
>
>     getXFromMapObjectPixel:function(moPixel){return moPixel.x;
>     },
>
>     getYFromMapObjectPixel:function(moPixel){return moPixel.y;
>     },
>
>     getMapObjectPixelFromXY:function(x,y){return new GPoint(x,y);
>     },
>
>     CLASS_NAME:"OpenLayers.Layer.Google"
>   }
> );
>
> Than it should work.
>
> Arnd Wippermann
>
> -----Ursprüngliche Nachricht-----
> Von: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] Im Auftrag von Ishikawa Hiroshi
> Gesendet: Mittwoch, 14. Februar 2007 03:15
> An: Christopher Schmidt
> Cc: OpenLayers ML
> Betreff: Re: [OpenLayers-Users] Disappear layers with large scale google maps
>
> Hi, Christopher
>
> I've tried your suggestion.
> But I cound't succeed probably my way was wrong.
>
> Could you show a sample?
>
> How should I change that? I copyed from the example page.
>   map = new OpenLayers.Map( $('map') ,
>   { controls: [new OpenLayers.Control.MouseDefaults()] , 'numZoomLevels':20});
>   var satellite = new OpenLayers.Layer.Google( "Google Satellite" , {type: G_NORMAL_MAP, 'maxZoomLevel':18} );
>   map.addLayers([satellite]);
>
>   var twms = new OpenLayers.Layer.WMS(
>     "World Map",
>     "http://world.freemap.in/cgi-bin/mapserv?",
>     {map: '/www/freemap.in/world/map/factbooktrans.map', transparent:'true', layers: 'factbook', 'format':'png'} );
>   map.addLayer(twms);
>
>
> On Tue, 13 Feb 2007 23:27:08 +0900, Ishikawa Hiroshi <ishikawa at geowork.co.jp> wrote:
>
>> Hi, Christopher
>>
>> Thanks for the reply.
>>
>> Ishikawa Hiroshi
>>
>> On Tue, 13 Feb 2007 21:41:24 +0900, Christopher Schmidt <crschmidt at metacarta.com> wrote:
>>
>>> On Tue, Feb 13, 2007 at 07:26:25PM +0900, Ishikawa Hiroshi wrote:
>>>> Dear all,
>>>>
>>>> I'm facing a problem that a layer disappear when I use with large scale google maps.
>>>> We can see this problem on the page that is an openlayers official example page.
>>>> http://openlayers.org/dev/examples/google.html
>>>>
>>>> There is a world map(coast line) layer on the page.
>>>> When I zoom in the largest zoom level or the 2nd largest zoom level
>>>> the check box become a disable status.
>>>>
>>>> Is this a bug or a regulation of google maps?
>>>
>>> This is a bug. You can change the behavior by adding 'numZoomLevels: 20'
>>> or something similar to your overlay when creating the layer. (This
>>> should be added as an option to the layer.)
>>>
>>> I'll file this as a bug to get fixed in 2.4.
>>>
>>> Regards,
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>>
>
>
>
> --
> ************************************
> 有限会社ジオ・ワーク 石川博司
> 〒514-8507 三重県津市栗真町屋町1577
> 三重大学 創造開発研究センター内
> TEL/FAX:059-231-5484
> http://www.geowork.co.jp
> E-Mail: ishikawa at geowork.co.jp
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
>



-- 
************************************
有限会社ジオ・ワーク 石川博司
〒514-8507 三重県津市栗真町屋町1577
三重大学 創造開発研究センター内
TEL/FAX:059-231-5484
http://www.geowork.co.jp
E-Mail: ishikawa at geowork.co.jp



More information about the Users mailing list