K_Reverter的网页开发记录

要么不做,要么就当作艺术品来做!

导航

Google Maps API 2.0解析(17-GSmallMapControl和GSmallZoomControl两个简单的控件)

        原来这俩个控件的代码这么简单
        //GSmallZoomControl控件
        function GSmallZoomControl()
        
{
        }

        GSmallZoomControl.prototype
=new GControl();
        GSmallZoomControl.prototype.initialize
=function(a)
        
{
            
var b=new GSize(17,35);
            
//创建控件层
            var c=CreateElement("div",a.getContainer(),null,b);
            
//加载控件图片
            CreateImage(getStaticImageUrl("szc"),c,GPoint.ORIGIN,b,true);
            
//创建图片上的可点击区域和触发的事件
            createClickArea(c,[[18,18,0,0,callback(a,a.zoomIn),_mZoomIn],[18,18,0,18,callback(a,a.zoomOut),_mZoomOut]]);
            
return c
        }
;
        GSmallZoomControl.prototype.getDefaultPosition
=function()
        
{
            
return new GControlPosition(0,new GSize(7,7))
        }
;
        
//GSmallMapControl控件
        function GSmallMapControl()
        
{
        }

        GSmallMapControl.prototype
=new GControl();
        GSmallMapControl.prototype.initialize
=function(a)
        
{
            
var b=new GSize(37,94);
            
var c=CreateElement("div",a.getContainer(),null,b);
            
//加载控件的图片,要注意的是,Google的控件是一个整体的图片
            CreateImage(getStaticImageUrl("smc"),c,GPoint.ORIGIN,b,true);
            createClickArea(c,[[
18,18,9,0,GetCallback(a,a.panDirection,0,1),_mPanNorth],[18,18,0,18,GetCallback(a,a.panDirection,1,0),_mPanWest],[18,18,18,18,GetCallback(a,a.panDirection,-1,0),_mPanEast],[18,18,9,36,GetCallback(a,a.panDirection,0,-1),_mPanSouth],[18,18,9,57,GetCallback(a,a.zoomIn),_mZoomIn],[18,18,9,75,GetCallback(a,a.zoomOut),_mZoomOut]]);
            
return c
        }
;
        GSmallMapControl.prototype.getDefaultPosition
=function()
        
{
            
return new GControlPosition(0,new GSize(7,7))
        }
;
      

posted on 2006-08-18 17:17  K_Reverter  阅读(2256)  评论(2编辑  收藏  举报