root / trunk / web / dojo / dojox / geo / charting / Map.js @ 13
History | View | Annotate | Download (2.67 KB)
1 | 9 | andrej.cim | /*
|
---|---|---|---|
2 | Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
||
3 | Available via Academic Free License >= 2.1 OR the modified BSD license.
|
||
4 | see: http://dojotoolkit.org/license for details
|
||
5 | */
|
||
6 | |||
7 | |||
8 | if(!dojo._hasResource["dojox.geo.charting.Map"]){ |
||
9 | dojo._hasResource["dojox.geo.charting.Map"]=true; |
||
10 | dojo.provide("dojox.geo.charting.Map");
|
||
11 | dojo.require("dojox.gfx");
|
||
12 | dojo.require("dojox.geo.charting._base");
|
||
13 | dojo.require("dojox.geo.charting._Feature");
|
||
14 | dojo.require("dojox.geo.charting._Marker");
|
||
15 | dojo.declare("dojox.geo.charting.Map",null,{defaultColor:"#B7B7B7",highlightColor:"#D5D5D5",series:[],constructor:function(_1,_2){ |
||
16 | dojo.style(_1,"display","block"); |
||
17 | this.containerSize={x:dojo.coords(_1).x,y:dojo.coords(_1).y,w:dojo.coords(_1).w||100,h:dojo.coords(_1).h||100}; |
||
18 | this.surface=dojox.gfx.createSurface(_1,this.containerSize.w,this.containerSize.h); |
||
19 | this.container=_1;
|
||
20 | this._createZoomingCursor();
|
||
21 | this.mapObj=this.surface.createGroup(); |
||
22 | this.mapObj.features={};
|
||
23 | dojo.xhrGet({url:_2,handleAs:"json",sync:true,load:dojo.hitch(this,"_init")}); |
||
24 | },setMarkerData:function(_3){ |
||
25 | dojo.xhrGet({url:_3,handleAs:"json",handle:dojo.hitch(this,"_appendMarker")}); |
||
26 | },setDataStore:function(_4,_5){ |
||
27 | this.dataStore=_4;
|
||
28 | var _6=this; |
||
29 | this.dataStore.fetch({query:_5,onComplete:function(_7){ |
||
30 | var _8=_7[0]; |
||
31 | var _9=_6.dataStore.getAttributes(_8);
|
||
32 | dojo.forEach(_9,function(_a){
|
||
33 | if(_6.mapObj.features[_a]){
|
||
34 | _6.mapObj.features[_a].setValue(_6.dataStore.getValue(_8,_a)); |
||
35 | } |
||
36 | }); |
||
37 | }}); |
||
38 | },addSeries:function(_b){ |
||
39 | this.series=_b;
|
||
40 | },_init:function(_c){ |
||
41 | var _d=_c.layerExtent[2]-_c.layerExtent[0]; |
||
42 | var _e=_c.layerExtent[3]-_c.layerExtent[1]; |
||
43 | this.mapObj.scale=Math.min(this.containerSize.w/_d,this.containerSize.h/_e); |
||
44 | this.mapObj.currentScale=this.mapObj.scale; |
||
45 | this.mapObj.boundBox=_c.layerExtent;
|
||
46 | this.mapObj.currentBBox={x:_c.layerExtent[0],y:_c.layerExtent[1]}; |
||
47 | this.mapObj.setTransform([dojox.gfx.matrix.scale(this.mapObj.scale),dojox.gfx.matrix.translate(-_c.layerExtent[0],-_c.layerExtent[1])]); |
||
48 | dojo.forEach(_c.featureNames,function(_f){
|
||
49 | var _10=_c.features[_f];
|
||
50 | _10.bbox.x=_10.bbox[0];
|
||
51 | _10.bbox.y=_10.bbox[1];
|
||
52 | _10.bbox.w=_10.bbox[2];
|
||
53 | _10.bbox.h=_10.bbox[3];
|
||
54 | var _11=new dojox.geo.charting._Feature(this,_f,_10); |
||
55 | _11.init(); |
||
56 | this.mapObj.features[_f]=_11;
|
||
57 | },this);
|
||
58 | this.mapObj.marker=new dojox.geo.charting._Marker({},this); |
||
59 | },_appendMarker:function(_12){ |
||
60 | this.mapObj.marker=new dojox.geo.charting._Marker(_12,this); |
||
61 | },_createZoomingCursor:function(){ |
||
62 | if(!dojo.byId("mapZoomCursor")){ |
||
63 | var _13=dojo.doc.createElement("div"); |
||
64 | dojo.attr(_13,"id","mapZoomCursor"); |
||
65 | dojo.addClass(_13,"mapZoomIn");
|
||
66 | dojo.style(_13,"display","none"); |
||
67 | dojo.body().appendChild(_13); |
||
68 | } |
||
69 | },onFeatureClick:function(_14){ |
||
70 | },onFeatureOver:function(_15){ |
||
71 | },onZoomEnd:function(_16){ |
||
72 | }}); |
||
73 | } |