You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by GitBox <gi...@apache.org> on 2019/12/06 05:05:37 UTC

[GitHub] [incubator-echarts] Conquer369 opened a new issue #11802: Add enablemapclick and maptype configuration in bmap extension will be better.

Conquer369 opened a new issue #11802: Add enablemapclick and maptype configuration in  bmap extension will be better.
URL: https://github.com/apache/incubator-echarts/issues/11802
 
 
   ### Version
   4.5.0
   
   ### Steps to reproduce
   ```javascript
   // BMapModel.js
   var _default = echarts.extendComponentModel({
     type: 'bmap',
     getBMap: function () {
       // __bmap is injected when creating BMapCoordSys
       return this.__bmap;
     },
     setCenterAndZoom: function (center, zoom) {
       this.option.center = center;
       this.option.zoom = zoom;
     },
     centerOrZoomChanged: function (center, zoom) {
       var option = this.option;
       return !(v2Equal(center, option.center) && zoom === option.zoom);
     },
     defaultOption: {
       center: [104.114129, 37.550339],
       zoom: 5,
       enableMapClick: false, // add enableMapClick config
       mapType: "BMAP_NORMAL_MAP", // add mapType config
       mapStyle: {},
       mapStyleV2: {},
       roam: false
     }
   });
   
   // BMapCoordSys.js
   BMapCoordSys.create = function (ecModel, api) {
     var bmapCoordSys;
     var root = api.getDom(); // TODO Dispose
   
     ecModel.eachComponent('bmap', function (bmapModel) {
       var painter = api.getZr().painter;
       var viewportRoot = painter.getViewportRoot();
   
       if (typeof BMap === 'undefined') {
         throw new Error('BMap api is not loaded');
       }
   
       Overlay = Overlay || createOverlayCtor();
   
       if (bmapCoordSys) {
         throw new Error('Only one bmap component can exist');
       }
   
       if (!bmapModel.__bmap) {
         // Not support IE8
         var bmapRoot = root.querySelector('.ec-extension-bmap');
   
         if (bmapRoot) {
           // Reset viewport left and top, which will be changed
           // in moving handler in BMapView
           viewportRoot.style.left = '0px';
           viewportRoot.style.top = '0px';
           root.removeChild(bmapRoot);
         }
   
         bmapRoot = document.createElement('div');
         bmapRoot.style.cssText = 'width:100%;height:100%'; // Not support IE8
   
         bmapRoot.classList.add('ec-extension-bmap');
         root.appendChild(bmapRoot);
         var bmap = bmapModel.__bmap = new BMap.Map(bmapRoot, {
            enableMapClick: bmapModel.get('enableMapClick') || false, // use enableMapClick config
         });
         var overlay = new Overlay(viewportRoot);
         bmap.addOverlay(overlay); // Override
   
         painter.getViewportRootOffset = function () {
           return {
             offsetLeft: 0,
             offsetTop: 0
           };
         };
       }
   
       var bmap = bmapModel.__bmap; // Set bmap options
       // centerAndZoom before layout and render
   
       var center = bmapModel.get('center');
       var zoom = bmapModel.get('zoom');
       var mapType = bmapModel.get('mapType'); // get mapType config
   
       if (center && zoom) {
         var pt = new BMap.Point(center[0], center[1]);
         bmap.centerAndZoom(pt, zoom);
       }
       
       // use mapType config
       switch(mapType) {
        case "BMAP_NORMAL_MAP":
          bmap.setMapType(BMAP_NORMAL_MAP);
          break;
        case "BMAP_SATELLITE_MAP":
          bmap.setMapType(BMAP_SATELLITE_MAP);
          break;
        case "BMAP_HYBRID_MAP":
          bmap.setMapType(BMAP_HYBRID_MAP);
          break;
        default:
          break;
      }
   
       bmapCoordSys = new BMapCoordSys(bmap, api);
       bmapCoordSys.setMapOffset(bmapModel.__mapOffset || [0, 0]);
       bmapCoordSys.setZoom(zoom);
       bmapCoordSys.setCenter(center);
       bmapModel.coordinateSystem = bmapCoordSys;
     });
     ecModel.eachSeries(function (seriesModel) {
       if (seriesModel.get('coordinateSystem') === 'bmap') {
         seriesModel.coordinateSystem = bmapCoordSys;
       }
     });
   };
   ```
   
   ### What is expected?
   wish to add enablemapclick and maptype configuration in  bmap extension.
   
   ### What is actually happening?
   now,it has no way to config enablemapclick and maptype.
   
   ---
   no
   
   <!-- This issue is generated by echarts-issue-helper. DO NOT REMOVE -->
   <!-- This issue is in English. DO NOT REMOVE -->

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org