1, Foreword
The function of exchanging address longitude and latitude is only available in online maps, because you need to go to the server to query the corresponding data and get the returned data. BMAP needs to be used in Baidu maps Geocoder realizes the exchange of these two functions. It has built-in getPoint function, which is responsible for converting the address into latitude and longitude coordinates, and getLocation function, which is responsible for converting the latitude and longitude coordinates into addresses. Therefore, these two functions are encapsulated into JS functions, which can be called directly every time.
The function of converting address and longitude and latitude is also often used. For example, the last route scheme query function. Previously, the official website provided direct input of Chinese characters of departure and destination to query the optimal route. Later, only the longitude and latitude coordinates of departure and destination can be input. This is a little around. Let users input what longitude and latitude coordinates, What the hell is that? Few users can understand it, so you need to first query the corresponding latitude and longitude coordinates of the Chinese characters of the starting point and destination entered by the user, and then input the query results into the JS function of route query. Why did you suddenly turn off the function of automatic longitude and latitude conversion of this address? I went to the backstage to have a look. It turned out that this function has become a charging module.
2, Functional features
- Both online map and offline map modes are supported.
- It also supports webkit kernel, webengine kernel, minilink kernel and IE kernel.
- Support setting multiple annotation points, including name, address, longitude and latitude.
- You can set whether the map can be clicked, dragged and zoomed with the mouse wheel.
- You can set the protocol version, secret key, theme style, central coordinate, central city, geocoding location, etc.
- You can set the zoom scale and level of the map, and the visibility of thumbnails, scale bars, road information and other controls.
- Support map interaction, such as mouse click to obtain the longitude and latitude of the corresponding position.
- It supports route query, and can set the starting point location, terminal location, route mode, route mode and route scheme (minimum time, minimum transfer, minimum walking, no subway, minimum distance and avoiding Expressway).
- It can display point, line and surface tools, and can directly draw lines, points, rectangles, circles, etc. on the map.
- You can set the administrative division, specify the drawing layer of a certain urban area, and automatically output the boundary points of the administrative division to the js file for the offline map.
- Multiple covers can be added statically or dynamically. Support point, polyline, polygon, rectangle, circle, arc, point aggregation, etc.
- Function interface is provided to process longitude and latitude resolution into address and address resolution into longitude and latitude coordinates.
- The provided demo can directly select points to perform corresponding processing, such as route query.
- You can get the point coordinate information set queried by the route, such as for robot coordinate navigation.
- It encapsulates rich functions, such as deleting specified points and all points, deleting specified covers and all covers, etc.
- The label point pop-up box information can be customized in standard html format.
- Mark point click event optional 0 - do not process 1 - pop up box 2 - send signal.
- Annotation points can be animated 0 - do not handle 1 - jump 2 - fall
- Label points can be set to local picture files, etc.
- The function interface is friendly and unified, simple and convenient to use, just one class.
- Support js dynamic interactive adding points, deleting points, clearing points and resetting points without refreshing the page.
- Support any Qt version, any system and any compiler.
3, Experience address
- Experience address: https://pan.baidu.com/s/1ZxG-oyUKe286LPMPxOrO2A Extraction code: o05q file name: bin_map.zip
- Domestic sites: https://gitee.com/feiyangqingyun
- International sites: https://github.com/feiyangqingyun
- Personal homepage: https://blog.csdn.net/feiyangqingyun
- Zhihu homepage: https://www.zhihu.com/people/feiyangqingyun/
4, Renderings
5, Related code
void MapBaiDu::addGeocoder(QStringList &list) { list << QString(" var geo = new %1.Geocoder();").arg(mapFlag); //Address resolved to coordinates list << QString(" function getPointByAddr(addr) {"); list << QString(" geo.getPoint(addr, function(result) {"); list << QString(" if (result) {"); list << QString(" var point = result.lng + ',' + result.lat;"); list << QString(" receiveData('geocoder', point);"); list << QString(" }"); list << QString(" });"); list << QString(" }"); //Resolve coordinates to addresses list << QString(" function getAddrByPoint(point) {"); list << QString(" geo.getLocation(getPoint(point), function(result) {"); list << QString(" if (result) {"); list << QString(" receiveData('geocoder', result.address);"); list << QString(" }"); list << QString(" });"); list << QString(" }"); } void frmMapBaiDu::on_btnAddrToPoint_clicked() { QString addr = ui->txtDeviceAddr->text().trimmed(); runJs(QString("getPointByAddr('%1')").arg(addr)); } void frmMapBaiDu::on_btnPointToAddr_clicked() { QString point = ui->txtDevicePoint->text().trimmed(); runJs(QString("getAddrByPoint('%1')").arg(point)); }