You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.9 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. *
  3. * This file is part of QMapControl,
  4. * an open-source cross-platform map widget
  5. *
  6. * Copyright (C) 2007 - 2008 Kai Winter
  7. * Copyright (C) 2014 Mattes Jaehne
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Lesser General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public License
  20. * along with QMapControl. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. * original software by Kai Winter
  23. * Contact e-mail: kaiwinter@gmx.de
  24. * Program URL : http://qmapcontrol.sourceforge.net/
  25. *
  26. * modified to use Google Static Maps API V2 by
  27. * Mattes Jaehne <mattes@dev.uavp.ch>
  28. * for
  29. * NGOS - The Next Generation multicopter OS
  30. * http://ng.uavp.ch
  31. *
  32. */
  33. #ifndef GOOGLEAPIMAPADAPTER_H
  34. #define GOOGLEAPIMAPADAPTER_H
  35. #include "qmapcontrol_global.h"
  36. #include "tilemapadapter.h"
  37. class googleApiMapadapter : public TileMapAdapter {
  38. //Q_OBJECT
  39. public:
  40. enum layerType
  41. {
  42. layerType_ROADMAP = 0, //displays the default road map view. This is the default map type.
  43. layerType_SATELLITE , //displays Google Earth satellite images
  44. layerType_HYBRID , //displays a mixture of normal and satellite views
  45. layerType_TERRAIN //displays a physical map based on terrain information
  46. };
  47. enum apiType
  48. {
  49. GoogleMapsAPI = 0,
  50. GoogleMapsForBusinessesAPI
  51. };
  52. googleApiMapadapter(layerType qMapType = layerType_ROADMAP, apiType qApiType = GoogleMapsAPI, QString qApiKey = "", QString qApiClientID = "", QString qServerAddress = "maps.googleapis.com");
  53. virtual ~googleApiMapadapter();
  54. virtual QPoint coordinateToDisplay(const QPointF&) const;
  55. virtual QPointF displayToCoordinate(const QPoint&) const;
  56. QString getHost() const;
  57. void setKey(QString apiKey);
  58. void setMapLayerType(layerType qMapType = layerType_ROADMAP);
  59. protected:
  60. virtual void zoom_in();
  61. virtual void zoom_out();
  62. virtual QString query(int x, int y, int z) const;
  63. virtual bool isValid(int x, int y, int z) const;
  64. virtual QString signURL( const QString& qURL, const QString& qCryptoKey ) const;
  65. private:
  66. QString typeToString( layerType qLayerType );
  67. virtual QString getQ(qreal longitude, qreal latitude, int zoom) const;
  68. qreal getMercatorLatitude(qreal YCoord) const;
  69. qreal getMercatorYCoord(qreal lati) const;
  70. qreal mCoord_per_x_tile;
  71. qreal mCoord_per_y_tile;
  72. QString mApiKey;
  73. QString mApiClientID;
  74. apiType mApiType;
  75. QString mMapLayerType;
  76. };
  77. #endif // GOOGLEAPIMAPADAPTER_H