OpenLayer

2654 단어 htmlextprototype
패널에 OpenLayer 통합
Ext.Panel에서 상속되는 MapPanel 확장
프로토타입에 넣기

MapPanel =function()
{
...
}
Ext.extend(MapPanel,Ext.Panel,{
	
	updateStatus:function(info)
	{
		Ext.fly(this.mapInfo.getEl()).update(" :"+info,true);
	}
	,initMap:function()
	{
		var lon = 5;
        var lat = 40;
        var zoom = 5;
        var map, layer;        
            map = new OpenLayers.Map( 'regionMap', { controls: [] } );//'regionMap' html div , MapPanel ContentEl 
      		//map = new OpenLayers.Map(mapPanel,{controls:[]});
            layer = new OpenLayers.Layer.WMS( "OpenLayers WMS", 
                    "http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
            map.addLayer(layer);

           var  vlayer = new OpenLayers.Layer.Vector( "Editable" );
            map.addLayer(vlayer);
            
            
           var zb = new OpenLayers.Control.ZoomBox(
                {title:"Zoom box: Selecting it you can zoom on an area by clicking and dragging."});
            var panel = new OpenLayers.Control.Panel({defaultControl: zb});
            panel.addControls([
                new OpenLayers.Control.MouseDefaults(
                    {title:'You can use the default mouse configuration'}), 
                zb,
                new OpenLayers.Control.DrawFeature(vlayer, OpenLayers.Handler.Path,
                    {title:'Draw a feature'}),
                new OpenLayers.Control.ZoomToMaxExtent({title:"Zoom to the max extent"}) 
            ]);
            map.addControl(panel);
            map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
            
            map.events.register("mousemove", map, function(e) { 
                var position = this.events.getMousePosition(e);
              	//Ext.fly(mapInfo.getEl()).update(" :"+position,true);
              	//this.updateStatus1(position);
                var mapPanel = Ext.getCmp("regionMap");
                if(mapPanel)
                	mapPanel.updateStatus(position);
                else
                	this.updateStatus(position);// prototype , function . 
            });
            this.doLayout();
	}
});

var mapPanel =new MapPanel();
mapPanel.initMap();
///
패널의 플러그인을 맞춤형으로 만들거나 확장하고 싶은데, 그럴 리가 없어요. 누가 가르쳐 줄 수 있어요?

좋은 웹페이지 즐겨찾기