Debian Codegraph @

dojox/geo/charting/widget/Map.js

raw symbols SCIP
1 define([
2 "dojo/_base/kernel",
3 "dojo/_base/lang",
4 "dojo/_base/declare",
5 "dojo/_base/html",
6 "dojo/dom-geometry",
7 "dijit/_Widget",
8 "../Map"
9 ], function(dojo, lang, declare, html,domGeom, Widget, Map){
10
11 return declare("dojox.geo.charting.widget.Map", Widget, {
12 // summary:
13 // A map viewer widget based on the dojox.geo.charting.Map component
14 // description:
15 // The `dojox.geo.charting.widget.Map` widget combines map display together with charting capabilities.
16 // It encapsulates an `dojox.geo.charting.Map` object on which most operations are delegated.
17 // Parameters can be passed as argument at construction time to specify map data file (json shape format)
18 // as well as charting data.
19 //
20 // The parameters are:
21 //
22 // - `shapeData`: The json object containing map data or the name of the file containing map data.
23 // - `dataStore`: the dataStore to fetch the charting data from
24 // - `dataBindingAttribute`: property name of the dataStore items to use as value for charting
25 // - `markerData`: tooltips to display for map features, handled as json style.
26 // - `adjustMapCenterOnResize`: if true, the center of the map remains the same when resizing the widget
27 // - `adjustMapScaleOnResize`: if true, the map scale is adjusted to leave the visible portion of the map identical as much as possible
28 //
29 // example:
30 // | var map = new dojox.geo.charting.widget.Map({
31 // | shapeData: 'map.json',
32 // | adjustMapCenterOnresize: true,
33 // | adjustMapScaleOnresize: true,
34 // | });
35
36 shapeData: "",
37 dataStore: null,
38 dataBindingAttribute: "",
39 dataBindingValueFunction: null,
40 markerData: "",
41 series: "",
42 adjustMapCenterOnResize: null,
43 adjustMapScaleOnResize: null,
44 animateOnResize: null,
45 onFeatureClick: null,
46 onFeatureOver: null,
47 enableMouseSupport: null,
48 enableTouchSupport: null,
49 enableMouseZoom: null,
50 enableMousePan: null,
51 enableKeyboardSupport: false,
52 showTooltips: false,
53 enableFeatureZoom: null,
54 colorAnimationDuration: 0,
55 mouseClickThreshold: 2,
56 _mouseInteractionSupport:null,
57 _touchInteractionSupport:null,
58 _keyboardInteractionSupport:null,
59 constructor: function(/* Object */options, /* HtmlNode */div){
60 // summary:
61 // Constructs a new Map widget
62 this.map = null;
63 },
64
65 startup: function(){
66 this.inherited(arguments);
67 if(this.map){
68 this.map.fitToMapContents();
69 }
70
71 },
72
73 postMixInProperties: function(){
74 this.inherited(arguments);
75 },
76
77 create: function(/*Object?*/params, /*DomNode|String?*/srcNodeRef){
78 this.inherited(arguments);
79 },
80
81 getInnerMap: function(){
82 return this.map;
83 },
84
85
86 buildRendering: function(){
87 this.inherited(arguments);
88 if(this.shapeData){
89 this.map = new Map(this.domNode, this.shapeData);
90 if(this.markerData && (this.markerData.length > 0)){
91 this.map.setMarkerData(this.markerData);
92 }
93
94 if(this.dataStore){
95 if(this.dataBindingValueFunction){
96 this.map.setDataBindingValueFunction(this.dataBindingValueFunction);
97 }
98 this.map.setDataStore(this.dataStore,this.dataBindingAttribute);
99 }
100
101 if(this.series && (this.series.length > 0)){
102 this.map.addSeries(this.series);
103 }
104
105 if(this.onFeatureClick){
106 this.map.onFeatureClick = this.onFeatureClick;
107 }
108 if(this.onFeatureOver){
109 this.map.onFeatureOver = this.onFeatureOver;
110 }
111 if(this.enableMouseSupport){
112 if(!dojox.geo.charting.MouseInteractionSupport){
113 throw Error("Can't find dojox.geo.charting.MouseInteractionSupport. Didn't you forget to dojo" + ".require() it?");
114 }
115 var options = {};
116 options.enablePan = this.enableMousePan;
117 options.enableZoom = this.enableMouseZoom;
118 options.mouseClickThreshold = this.mouseClickThreshold;
119 this._mouseInteractionSupport = new dojox.geo.charting.MouseInteractionSupport(this.map,options);
120 this._mouseInteractionSupport.connect();
121 }
122
123 if(this.enableTouchSupport){
124 if(!dojox.geo.charting.TouchInteractionSupport){
125 throw Error("Can't find dojox.geo.charting.TouchInteractionSupport. Didn't you forget to dojo" + ".require() it?");
126 }
127 this._touchInteractionSupport = new dojox.geo.charting.TouchInteractionSupport(this.map,{});
128 this._touchInteractionSupport.connect();
129 }
130 if(this.enableKeyboardSupport){
131 if(!dojox.geo.charting.KeyboardInteractionSupport){
132 throw Error("Can't find dojox.geo.charting.KeyboardInteractionSupport. Didn't you forget to dojo" + ".require() it?");
133 }
134 this._keyboardInteractionSupport = new dojox.geo.charting.KeyboardInteractionSupport(this.map,{});
135 this._keyboardInteractionSupport.connect();
136 }
137 this.map.showTooltips = this.showTooltips;
138 this.map.enableFeatureZoom = this.enableFeatureZoom;
139 this.map.colorAnimationDuration = this.colorAnimationDuration;
140 }
141 },
142
143 resize : function(/*Object|Number?*/ b, /*Number?*/ height){
144 // summary:
145 // Resize the widget.
146 // description:
147 // Resize the domNode and the widget to the dimensions of a box of the following form:
148 // `{ l: 50, t: 200, w: 300: h: 150 }`
149 // b: Object|Number?
150 // An hash with optional "l", "t", "w", and "h" properties for "left", "right", "width", and "height"
151 // respectively; or a number representing the new width.
152 // height: Number?
153 // A number representing the new height.
154
155 var box;
156 switch(arguments.length){
157 case 0:
158 // case 0, do not resize the div, just the surface
159 break;
160 case 1:
161 // argument, override node box
162 box = lang.mixin({}, b);
163 domGeom.setMarginBox(this.domNode, box);
164 break;
165 case 2:
166 // two argument, width, height
167 box = {
168 w: arguments[0],
169 h: arguments[1]
170 };
171 domGeom.setMarginBox(this.domNode, box);
172 break;
173 }
174
175 if(this.map){
176 this.map.resize(this.adjustMapCenterOnResize,this.adjustMapScaleOnResize,this.animateOnResize);
177 }
178 }
179 });
180 });