geo.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. var echarts = require("../echarts");
  20. var zrUtil = require("zrender/lib/core/util");
  21. require("../coord/geo/GeoModel");
  22. require("../coord/geo/geoCreator");
  23. require("./geo/GeoView");
  24. require("../action/geoRoam");
  25. /*
  26. * Licensed to the Apache Software Foundation (ASF) under one
  27. * or more contributor license agreements. See the NOTICE file
  28. * distributed with this work for additional information
  29. * regarding copyright ownership. The ASF licenses this file
  30. * to you under the Apache License, Version 2.0 (the
  31. * "License"); you may not use this file except in compliance
  32. * with the License. You may obtain a copy of the License at
  33. *
  34. * http://www.apache.org/licenses/LICENSE-2.0
  35. *
  36. * Unless required by applicable law or agreed to in writing,
  37. * software distributed under the License is distributed on an
  38. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  39. * KIND, either express or implied. See the License for the
  40. * specific language governing permissions and limitations
  41. * under the License.
  42. */
  43. function makeAction(method, actionInfo) {
  44. actionInfo.update = 'updateView';
  45. echarts.registerAction(actionInfo, function (payload, ecModel) {
  46. var selected = {};
  47. ecModel.eachComponent({
  48. mainType: 'geo',
  49. query: payload
  50. }, function (geoModel) {
  51. geoModel[method](payload.name);
  52. var geo = geoModel.coordinateSystem;
  53. zrUtil.each(geo.regions, function (region) {
  54. selected[region.name] = geoModel.isSelected(region.name) || false;
  55. });
  56. });
  57. return {
  58. selected: selected,
  59. name: payload.name
  60. };
  61. });
  62. }
  63. makeAction('toggleSelected', {
  64. type: 'geoToggleSelect',
  65. event: 'geoselectchanged'
  66. });
  67. makeAction('select', {
  68. type: 'geoSelect',
  69. event: 'geoselected'
  70. });
  71. makeAction('unSelect', {
  72. type: 'geoUnSelect',
  73. event: 'geounselected'
  74. });