The project requirements, click on a saved polygon or circular area, you can quickly locate the area, display it on the map, don't talk nonsense, let's look at the renderings first!
As shown in the picture above, we click on the tab on the right to quickly locate the area where the tab is saved
At first, I thought Baidu had a ready-made interface to provide us with calls, but the result was not, and then, from the Internet search, I didn't find any relevant information, so I can only rely on myself, we use the class reference provided by Baidu to achieve the above effect.
getViewport to get the best view of the map based on the geographic area or coordinates provided, returning objects with center and zoom attributes that represent the center point and level of the map, respectively. This method only returns field of view information and does not apply new center points and levels to the current map
This is how we can get the best center point and the best scale for the area
(Circle, in fact, you can get the center point, but you can't get the best scale)
The code is as follows:
Circular area code
Tourists, if you want to see the hidden content of this post, please Reply
Polygon, Rectangle Code:
Tourists, if you want to see the hidden content of this post, please Reply Note: You must set the zoom level before moving the center point!!!!
|