One, foreword

Map types are mainly two kinds, street and satellite image, we see at ordinary times the default are street, street map or satellite image is composed of image files, the higher the level, the more clear images, are generally support to 19th level map, equivalent to accurate to within 20 meters of the image, it has fully used the enough, The highest level of accuracy is commercially available map data. Street maps are sufficient for most applications, but a few require satellite images to see the landscape.

Satellite map, referred to as satellite map, the exact term is satellite remote sensing image, also known as satellite image. The so-called remote sensing, namely remote perception. Satellite remote sensing is to detect the reflection and electromagnetic wave emitted by the objects on the earth’s surface through the satellite in space, so as to extract the information of these objects and complete the long-distance identification of objects. These radio wave information conversion, recognition of the image, that is, satellite map.

Baidu Map or other maps provide codes to set the default map and switch the hover button quickly. For example, the hover switch button is placed in the upper right corner. After the map type is switched, the latitude and longitude coordinates of the original device are universal without any change.

Two, functional characteristics

  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. 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::addProperty(QStringList &list)
{
    if (mapType == 0) {
        // Define map objects
        // The default street map or satellite map can be set: BMAP_NORMAL_MAP Satellite map: BMAP_SATELLITE_MAP
        list << QString("  var map = new%1.Map('map', {minZoom:%2, maxZoom:%3, enableMapClick:%4, mapType:%5});" ) .arg(mapFlag).arg(mapMinZoom).arg(mapMaxZoom).arg(enableMapClick ? "true":"false").arg("BMAP_NORMAL_MAP");
        list << QString("  var point = new%1.Point(%2);" ).arg(mapFlag).arg(mapCenterPoint); }else if(! MapLocal) {// Only online maps have several othersif(mapType == 1) {// Set the map type to Earth mode and change the BMap object to BMapGL << QString(" var map == 1)newBMapGL.Map('map');" ); list << QString(" var point =newBMapGL.Point(%1);" ).arg(mapCenterPoint); list << QString(" map.setMapType(BMAP_EARTH_MAP);" ); }else if (mapType == 2) {
            list << QString("  var map = newBMapGL.Map('map');" ); list << QString(" var point =newBMapGL.Point(%1);" ).arg(mapCenterPoint); }else if(mapType == 3) { list << QString(" var subwayCityName = '%1';" ).arg(mapCenterCity); list << QString(" var list = BMapSub.SubwayCitiesList;" ); list << QString(" var subwaycity = null;" ); list << QString(" var count = list.length;" ); list << QString("for (var i = 0; i < count; ++i) {");
            list << QString("    if(list[i].name === subwayCityName) {"); list << QString(" subwaycity = list[i];" ); list << QString("break;" ); list << QString(" }"); list << QString(" }"); list << QString(" var map =newBMapSub.Subway('map', subwaycity.citycode);" ); list << QString(" var zoomControl =new BMapSub.ZoomControl({");
            list << QString("  anchor: BMAPSUB_ANCHOR_BOTTOM_RIGHT,");
            list << QString("  offset: newBMapSub. Size (10100) "); list << QString(" });" ); list << QString(" map.addControl(zoomControl);" ); A list < < QString (" map. SetZoom (0.5);" ); }} // Initialize the map and set the central point coordinates or the central city and map level. // Offline maps need to take the form of central coordinatesif(! mapCenterPoint.isEmpty()) { list << QString(" map.centerAndZoom(point, %1);" ).arg(mapZoom); }else{ list << QString(" map.centerAndZoom(\"%1\", %2);" ).arg(mapCenterCity).arg(mapZoom); }if(! List << QString(" map.setheading (64.5);" ); list << QString(" map.setTilt(73);" ); } // Enable map drag events, enabled by default (no writing)if(enableDragging) { list << QString(" map.enableDragging();" ); } // Enable the scroll wheel zoom in and out, disabled by defaultif(enableScrollWheelZoom) { list << QString(" map.enableScrollWheelZoom();" ); } // Enable double click to enlarge, default enabled (no write)if(enableDoubleClickZoom) { list << QString(" map.enableDoubleClickZoom();" ); } // Enable keyboard movement, disabled by defaultif(enableKeyboard) { list << QString(" map.enableKeyboard();" ); } / / to enable the map of inertial drag, disabled by default list < < QString (" map. EnableInertialDragging ();" ); List << QString(" map.enablecontinuousZoom (); ); List << QString(" map.enablePinchtoZoom (); ); List << QString(" map.enableAutoresize (); ); // Add a zoom control to the mapif (showNavigationControl) {
        list << QString("  map.addControl(new%1.NavigationControl({anchor:BMAP_ANCHOR_TOP_LEFT, type:BMAP_NAVIGATION_CONTROL_LARGE}));" ).arg(mapFlag); } // Add a thumbnail control to the mapif (showOverviewMapControl) {
        list << QString("  map.addControl(new%1.OverviewMapControl({anchor:BMAP_ANCHOR_BOTTOM_RIGHT, isOpen:1}));" ).arg(mapFlag); } // Add a scale control to the mapif (showScaleControl) {
        list << QString("  map.addControl(new%1.ScaleControl({anchor:BMAP_ANCHOR_BOTTOM_LEFT}));" ).arg(mapFlag); } // Add map type controls, default is empty, street map + satellite map + 3D map haveif(showMapTypeControl) {// Street map :BMAP_NORMAL_MAP Satellite map :BMAP_SATELLITE_MAP Hybrid map :BMAP_HYBRID_MAP 3D map :BMAP_PERSPECTIVE_MAP  QString(" map.addControl(new%1.MapTypeControl({mapTypes:[BMAP_NORMAL_MAP,BMAP_SATELLITE_MAP]}));" ).arg(mapFlag); } // Add panorama controlif (showPanoramaCoverageLayer) {
        list << QString("  map.addTileLayer(new%1.PanoramaCoverageLayer());" ).arg(mapFlag); list << QString(" var ctrlPan =new%1.PanoramaControl();" ).arg(mapFlag); list << QString(" ctrlPan.setOffset(new%1.Size(20, 50));" ).arg(mapFlag); list << QString(" map.addControl(ctrlPan);" ); } // Add road condition control, offline map does not have real-time road conditionif(showTrafficControl && ! mapLocal) { list << QString(" var ctrlTra =new %1Lib.TrafficControl({showPanel:false});" ).arg(mapFlag); list << QString(" ctrlTra.setAnchor(BMAP_ANCHOR_BOTTOM_RIGHT);" ); list << QString(" map.addControl(ctrlTra);" ); } // Set the color theme,2019-6 start charging, shielding the following line can be usedif(! mapStyleName.isEmpty()) { //list<< QString(" map.setMapStyle({style:'%1'});" ).arg(mapStyleName); } // Set the mouse click to get latitude and longitude, sent by signalif(enableClickPoint) { list << QString(" map.addEventListener('click', function(e) {"); list << QString(" var point = e.point.lng + ',' + e.point.lat;" ); list << QString(" receiveData('point', point);" ); list << QString(" });" ); } #if0 // Some devices require the mouse wheel to zoom through the event mechanismif(enableScrollWheelZoom) { list << QString(" window.addEventListener('mousewheel', function(e) {"); list << QString(" var wheel = e.wheelDelta;" ); list << QString("if(wheel > 0) {"); list << QString(" map.zoomIn();" ); list << QString(" }else{"); list << QString(" map.zoomOut();" ); list << QString(" }"); list << QString(" });" ); } #endif }Copy the code