One, foreword

In map applications, it is sometimes necessary to open the suspension toolbar, so that users can directly draw rectangles, polygons, circles and lines on the map. Therefore, it is necessary to provide a function interface to obtain the corresponding information of these shapes drawn by users. For example, coordinate points, the center and radius of a circle, and the set of coordinate points for the Path of all shapes are all in the form of latitude and longitude coordinates. Generally encapsulated JS functions with similar functions have three requirements. The first one is passed in null value to find all coverings; the second one is passed in type to find all coverings of this type, such as rectangles; the third one is passed in object name to find those that match the name. Trying to get all of the coverings through map.getoverlays () was a difficult task for beginners. The initial strategy I was thinking about was how to get one type of coverings ToString () can get the words [object Marker] [object Circle] [object Overlay], so it filters the type. Then it finds that the js general keyword instanceof can also achieve this function. For example, if (overlay instanceof map.circle) can determine if the overlay is round.

Map module in a number of places are used to convert getPath function to get the path into the coordinate point collection string out, such as Qt application processes, so that encapsulates a general transformation function, specially the paths to string the coordinates of the point set, in English a comma between latitude and longitude, separated, make a coordinate between the semicolon in English; Separated, a number of different parameter values in English vertical bar | is separated, the unified rules are common in all functions and interactions. In the browser controls of the early WebKit kernel, for example, there was no way to pass out arrays of arrays, so it had to be converted into all-purpose string combinations.

Two, functional characteristics

1. Functional features of provincial and regional map encapsulation

  1. It also supports flash map, migration map, regional map, world map, dashboard, etc.
  2. You can set title, prompt message, background color, text color, line color, region color, and other colors.
  3. You can set the name, value, latitude and longitude of the city.
  4. Map magnification can be set, whether to allow the mouse wheel zoom.
  5. Built-in world map, national map, provincial map, regional map, can be accurate to county, all maps are offline use.
  6. Built-in json data files of various provinces and cities to JS file function, such as data update can be converted by themselves, support single file conversion and one key conversion of all files.
  7. Built-in function to obtain all the name and latitude and longitude information set of the region from JSON file or JS file, you can use this method to obtain information for display.
  8. Depend on the browser component display maps, provide the demo support its page loading/webengine/miniblink/ie many ways.
  9. The miniblink browser kernel eliminates the lack of browser modules in Qt5.6 and later +mingw compilers, enabling the entire project to support all Qt versions and test any version from 4.7 to 6.2.
  10. Flicker dot migration map and other Settings of the dot support separate Settings color.
  11. Provide interface to directly obtain click point information, convenient program linkage processing.
  12. Expand sex is extremely strong, can in the gourd painting gourd ladle to increase all kinds of exquisite echarts components, make the effect of the cow force.
  13. The built-in dashboard component provides interactive functionality, which is included in the demo.
  14. Function interface friendly and unified, easy to use, a class.
  15. Support any Qt version, any system, any compiler.

2. Functions and features of Baidu Map encapsulation class

  1. Both online map and offline map modes are supported.
  2. Support webKit kernel, WebEngine kernel, miniblink kernel, IE kernel.
  3. You can set multiple annotation points, including name, address, longitude and latitude.
  4. You can set whether the map can be zoomed by clicking, dragging or mouse wheel.
  5. You can set the protocol version, key, theme style, central coordinate, central city, geocoding location, etc.
  6. Map zoom scale and level can be set, thumbnail, scale, road information and other controls visible.
  7. Support map interaction, such as mouse down to get the longitude and latitude of the corresponding location.
  8. Support route query, you can set the starting point location, destination location, route mode, route mode, route scheme (minimum time, minimum transfer, minimum walking, no subway, shortest distance, avoid high-speed).
  9. Can display point line plane tool, can directly on the map line, point, rectangle, circle, etc.
  10. Administrative divisions can be set up to specify a certain urban area to draw layers. The online map automatically outputs the boundary points of administrative divisions to JS files for offline map use.
  11. Multiple coverings can be added statically or dynamically. Supports point, polygon, rectangle, circle, arc, point aggregation, etc.
  12. Provides a function interface to handle latitude and longitude resolution into addresses and address resolution into latitude and longitude coordinates.
  13. The demo can directly select individual points to perform corresponding processing such as route query.
  14. You can get the point coordinate information set queried by the route, such as for robot coordinate navigation.
  15. Encapsulates rich functions such as delete specified point and all points, delete specified overlay and all overlay, etc.
  16. Annotate popbox information can be customized content, standard HTML format.
  17. Annotation point Click event Optional 0- Do not process 1- Own pop-up 2- Send signal.
  18. Annotation point can set animation effect 0- no processing 1- jump 2- fall
  19. Note points can be set to local image files.
  20. Function interface friendly and unified, easy to use, a class.
  21. Js dynamic interaction to add points, delete points, empty points, reset points, do not need to refresh the page.
  22. Support any Qt version, any system, any compiler.

3 Features of offline map download

  1. Multi-thread synchronous download multi-level tile map, card interface.
  2. Built-in multiple offline map download request address, automatically select a random send request.
  3. Download map types support both street maps and satellite maps.
  4. Automatically calculates the number of downloaded tiles in the viewable area or administrative area.
  5. The level of download can be custom scoped and selected.
  6. Signal notification is sent for each tile download completion, and parameters include download time.
  7. You can set the maximum timeout time for downloading. If the timeout time is exceeded, it will be discarded and skip to the next download task.
  8. Real-time display of the download progress, as well as the number of tiles downloaded at the current level and total number of tiles.
  9. The download can be stopped during the download process, and the total time is automatically counted after the download is completed.
  10. Built-in latitude and longitude and screen coordinate conversion function.
  11. Baidu Map is currently supported, and other maps such as Google Map, Tencent Map and Autonavi map can be customized.
  12. Function interface friendly and unified, easy to use, a class.
  13. Support any Qt version, any system, any compiler.

4 provinces and cities outline download function features

  1. Timer queue download provinces and cities contour map point coordinate set stored in JS file.
  2. Support for multiple irregular region downloads in one administrative region.
  3. Automatically calculates the number of download profiles for administrative regions.
  4. You can select the exact province, city, or county, or directly enter the name of the administrative region.
  5. You can set the download interval, start the download at any time and stop the download.
  6. Provide edit boundary function, you can directly edit the point set of irregular regions on the map, and then obtain the boundary point set data, which can be used to draw their own region to get data, such as a town or even a small administrative region data, very cool.

3. Experience address

  1. Experience address: pan.baidu.com/s/1ZxG-oyUK… Extraction code: O05q File name: bin_map.zip
  2. Domestic site: gitee.com/feiyangqing…
  3. International site: github.com/feiyangqing…
  4. Profile: blog.csdn.net/feiyangqing…
  5. Zhihu homepage: www.zhihu.com/people/feiy…

Four, effect drawing

5. Relevant codes

void MapBaiDu::addLocalSearch(QStringList &list)
{
    // The results of the global search object can be displayed on the map or notified asynchronously
#if 1list << QString(" var searchOptions = {renderOptions:{map: map}};" ); #else
    list << QString("  var searchOptions = {");
    list << QString("    onSearchComplete: function(results) {");
    list << QString("      if(local.getStatus() ! = BMAP_STATUS_SUCCESS) {"); list << QString("return;" ); list << QString(" }"); list << QString(" var result = [];" ); list << QString(" var count = results.getCurrentNumPois();" ); list << QString("for(var i = 0; i < count; ++i) {"); list << QString(" var poi = results.getPoi(i);" ); list << QString(" var point = poi.point.lng + ',' + poi.point.lat;" ); list << QString(" result.push(point + '; ' + poi.title + '; ' + poi.address + '; ' + poi.url);" ); list << QString(" }"); list << QString(" receiveData('searchresult', result.join('|'));" ); list << QString(" }"); list << QString(" };" ); #endif list << QString(" var local =new%1.LocalSearch(map, searchOptions);" ).arg(mapFlag); list << QString(" local.setSearchCompleteCallback(function(results) {"); list << QString(" "); list << QString(" });" ); / / / / text: universal search method search keywords Support multiple can be separated by | list < < QString (" function search (text) {"); list << QString(" var texts = text.split('|');" ); list << QString(" local.search(texts);" ); list << QString(" }"); List << QString(" function searchInBounds(text, start, end) {"); list << QString(" var texts = text.split('|');" ); list << QString("if(! start || ! end) {"); list << QString(" local.searchInBounds(texts, map.getBounds());" ); list << QString("return;" ); list << QString(" }"); list << QString(" var bs =new%1.Bounds(getPoint(start), getPoint(end));" ).arg(mapFlag); list << QString(" local.searchInBounds(texts, bs);" ); list << QString(" }"); List << QString(" function searchNearby(text, center, radius) {"); list << QString(" var texts = text.split('|');" ); list << QString(" local.searchNearby(texts, getPoint(center), radius);" ); list << QString(" }"); }voidMapbidu ::getOverlayInfo(QStringList &list) {type = Marker Polyline list << QString(" function" getOverlayInfo(type) {"); list << QString(" var allOverlay = map.getOverlays();" ); list << QString(" var count = allOverlay.length;" ); list << QString("for(var i = 0; i < count; ++i) {"); list << QString(" var overlay = allOverlay[i];" ); // Filter invisible list << QString("if(! overlay.isVisible()) {"); list << QString("continue;" ); list << QString(" }"); [Overlay] [object Marker] [object Circle] [Object Overlay] list << QString(" var objType = overlay.toString();" ); list << QString(" objType = objType.substr(8, objType.length - 9);" ); // List << QString("if (objType == 'Marker' || objType == 'Overlay') {");
    list << QString("        continue;" ); list << QString(" }"); List << QString("if(type.length > 0 && objType ! = type) {"); list << QString("continue;" ); list << QString(" }"); list << QString(" var path = overlay.getPath();" ); list << QString(" var points = getPathPoints(path);" ); Instanceof list << QString(" var info = objType;" ); list << QString("if(overlay instanceof %1.Circle) {").arg(mapFlag); list << QString(" var center = overlay.getCenter();" ); list << QString(" var point = center.lng + ',' + center.lat;" ); list << QString(" var radius = overlay.getRadius();" ); list << QString(" info = objType + '|' + point + '|' + radius + '|' + points.join('; ') "); list << QString(" }else{"); list << QString(" info = objType + '|' + points.join('; ') "); list << QString(" }"); list << QString(" receiveData('overlayinfo', info);" ); list << QString(" }"); list << QString(" }"); }Copy the code