_Marker.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. define("dojox/geo/charting/_Marker", ["dojo/_base/lang","dojo/_base/array", "dojo/_base/declare","dojo/_base/sniff","./_base"],
  2. function(lang, arr, declare, has) {
  3. return declare("dojox.geo.charting._Marker", null, {
  4. _needTooltipRefresh: null,
  5. _map: null,
  6. constructor: function(markerData, map){
  7. this._map = map;
  8. var mapObj = map.mapObj;
  9. this.features = mapObj.features;
  10. this.markerData = markerData;
  11. _needTooltipRefresh = false;
  12. },
  13. show: function(featureId,evt){
  14. this.currentFeature = this.features[featureId];
  15. if (this._map.showTooltips && this.currentFeature) {
  16. this.markerText = this.currentFeature.markerText || this.markerData[featureId] || featureId;
  17. dojox.geo.charting.showTooltip(this.markerText, this.currentFeature.shape, ["before"]);
  18. }
  19. this._needTooltipRefresh = false;
  20. },
  21. hide: function(){
  22. if (this._map.showTooltips && this.currentFeature)
  23. dojox.geo.charting.hideTooltip(this.currentFeature.shape);
  24. this._needTooltipRefresh = false;
  25. },
  26. _getGroupBoundingBox: function(group){
  27. var shapes = group.children;
  28. var feature = shapes[0];
  29. var bbox = feature.getBoundingBox();
  30. this._arround = lang.clone(bbox);
  31. arr.forEach(shapes, function(item){
  32. var _bbox = item.getBoundingBox();
  33. this._arround.x = Math.min(this._arround.x, _bbox.x);
  34. this._arround.y = Math.min(this._arround.y, _bbox.y);
  35. },this);
  36. },
  37. _toWindowCoords: function(arround, coords, containerSize){
  38. var toLeft = (arround.x - this.topLeft[0]) * this.scale;
  39. var toTop = (arround.y - this.topLeft[1]) * this.scale
  40. if (has("ff") == 3.5) {
  41. arround.x = coords.x;
  42. arround.y = coords.y;
  43. }
  44. else if (has("chrome")) {
  45. arround.x = containerSize.x + toLeft;
  46. arround.y = containerSize.y + toTop;
  47. }
  48. else {
  49. arround.x = coords.x + toLeft;
  50. arround.y = coords.y + toTop;
  51. }
  52. arround.width = (this.currentFeature._bbox[2]) * this.scale;
  53. arround.height = (this.currentFeature._bbox[3]) * this.scale;
  54. arround.x += arround.width / 6;
  55. arround.y += arround.height / 4;
  56. }
  57. });
  58. });