_Marker.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. Copyright (c) 2004-2012, 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. if(!dojo._hasResource["dojox.geo.charting._Marker"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
  7. dojo._hasResource["dojox.geo.charting._Marker"] = true;
  8. dojo.provide("dojox.geo.charting._Marker");
  9. dojo.declare("dojox.geo.charting._Marker", null, {
  10. constructor: function(markerData, map){
  11. var mapObj = map.mapObj;
  12. this.features = mapObj.features;
  13. this.markerData = markerData;
  14. },
  15. show: function(featureId){
  16. this.markerText = this.features[featureId].markerText || this.markerData[featureId] || featureId;
  17. this.currentFeature = this.features[featureId];
  18. dojox.geo.charting.showTooltip(this.markerText, this.currentFeature.shape, "before");
  19. },
  20. hide: function(){
  21. dojox.geo.charting.hideTooltip(this.currentFeature.shape);
  22. },
  23. _getGroupBoundingBox: function(group){
  24. var shapes = group.children;
  25. var feature = shapes[0];
  26. var bbox = feature.getBoundingBox();
  27. this._arround = dojo.clone(bbox);
  28. dojo.forEach(shapes, function(item){
  29. var _bbox = item.getBoundingBox();
  30. this._arround.x = Math.min(this._arround.x, _bbox.x);
  31. this._arround.y = Math.min(this._arround.y, _bbox.y);
  32. },this);
  33. },
  34. _toWindowCoords: function(arround, coords, containerSize){
  35. var toLeft = (arround.x - this.topLeft[0]) * this.scale;
  36. var toTop = (arround.y - this.topLeft[1]) * this.scale
  37. if (dojo.isFF == 3.5) {
  38. arround.x = coords.x;
  39. arround.y = coords.y;
  40. }
  41. else if (dojo.isChrome) {
  42. arround.x = containerSize.x + toLeft;
  43. arround.y = containerSize.y + toTop;
  44. }
  45. else {
  46. arround.x = coords.x + toLeft;
  47. arround.y = coords.y + toTop;
  48. }
  49. arround.width = (this.currentFeature._bbox[2]) * this.scale;
  50. arround.height = (this.currentFeature._bbox[3]) * this.scale;
  51. arround.x += arround.width / 6;
  52. arround.y += arround.height / 4;
  53. }
  54. });
  55. }