| 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 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 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(options, div){ |
| 60 |
|
| 61 |
|
| 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(params, 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( b, height){ |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
var box; |
| 156 |
switch(arguments.length){ |
| 157 |
case 0: |
| 158 |
|
| 159 |
break; |
| 160 |
case 1: |
| 161 |
|
| 162 |
box = lang.mixin({}, b); |
| 163 |
domGeom.setMarginBox(this.domNode, box); |
| 164 |
break; |
| 165 |
case 2: |
| 166 |
|
| 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 |
}); |