echarts-bot[bot] commented on issue #18132:
URL: https://github.com/apache/echarts/issues/18132#issuecomment-1369561127

   @howiekang It seems you are not using English, I've helped translate the 
content automatically. To make your issue understood by more people and get 
helped, we'd like to suggest using English next time. 🤗
   <details><summary><b>TRANSLATED</b></summary><br>
   
   **TITLE**
   
   [Feature] How to get a BMap instance in EChart
   
   **BODY**
   
   ### What problem does this feature solve?
   
   I want to select any point on the map in EChart (not the location that 
EChart has drawn on the map, but just click on a certain place on the map), and 
the left side of the clicked point can be obtained. What should I do? ? ?
   
   Vue version: ^3.2.33
   Map: Baidu map
   EChart version: ^5.4.1
   
   Methods that have been tried so far:
   1 through the following code
     ```
   echarts.registerTheme('theme', EChartsTheme.theme);
     const myChart = echarts.init(document.getElementById('projectMap')!, 
'theme');
     //Try to get the map instance
     const map = myChart.getModel().getComponent('bmap').getBMap();
   ```
    I refer to the official extension of Baidu map in EChart, but 
`myChart.getModel().getComponent('bmap').getBMap()` this code reports an error. 
The specific error is `Uncaught (in promise) TypeError: Cannot read properties 
of undefined (reading 'getComponent')`
   2 
   ```
   echarts.registerTheme('theme', EChartsTheme.theme);
     const myChart = echarts.init(document.getElementById('projectMap')!, 
'theme');
     const bmap = echarts. getMap('bmap');
     //An error is reported here, addEventListener does not exist
     bmap. addEventListener('click', function (e) {
       alert('click!');
     });
   ```
   3 Try to find the relevant map instance by printing the current window 
object.
   
   None of the above methods were successful.
   
   I currently have two ideas:
   1 Get the instance of the map in EChart, and then you can operate it 
casually.
   2 Through the things in EChart, directly control the click.
   
   ### What does the proposed API look like?
   
   Get the BMap object directly
   </details>


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to