Skip to content

Commit 5dfd74c

Browse files
authored
Merge pull request vladest#4 from sportproll/master
- Added place search suggestion feature (similar to Nokia)
2 parents 19f03b1 + cba78d8 commit 5dfd74c

13 files changed

+443
-66
lines changed

googlemaps.pro

100644100755
+6-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ HEADERS += \
1717
qgeomapreplygooglemaps.h \
1818
qgeotiledmapgooglemaps.h \
1919
qgeotiledmappingmanagerenginegooglemaps.h \
20-
qgeotilefetchergooglemaps.h
20+
qgeotilefetchergooglemaps.h \
21+
qplacesearchsuggestionreplyimpl.h \
22+
qgeoerror_messages.h
2123

2224
SOURCES += \
2325
qgeoserviceproviderplugingooglemaps.cpp \
@@ -31,7 +33,9 @@ SOURCES += \
3133
qgeomapreplygooglemaps.cpp \
3234
qgeotiledmapgooglemaps.cpp \
3335
qgeotiledmappingmanagerenginegooglemaps.cpp \
34-
qgeotilefetchergooglemaps.cpp
36+
qgeotilefetchergooglemaps.cpp \
37+
qplacesearchsuggestionreplyimpl.cpp \
38+
qgeoerror_messages.cpp
3539

3640

3741
OTHER_FILES += \

googlemaps_plugin.json

100644100755
+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"ReverseGeocodingFeature",
99
"OnlineRoutingFeature",
1010
"AlternativeRoutesFeature",
11-
"OnlinePlacesFeature",
12-
"OnlineMappingFeature"
11+
"OnlineMappingFeature",
12+
"SearchSuggestionsFeature"
1313
]
1414
}

qgeocodingmanagerenginegooglemaps.cpp

100644100755
+4-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ QGeoCodingManagerEngineGooglemaps::QGeoCodingManagerEngineGooglemaps(const QVari
3737
else
3838
m_userAgent = "Qt Location based application";
3939

40-
m_apiKey = parameters.value(QStringLiteral("googlemaps.geocode.apikey")).toString();
40+
if(parameters.contains((QStringLiteral("googlemaps.geocode.apikey"))))
41+
m_apiKey = parameters.value(QStringLiteral("googlemaps.geocode.apikey")).toString();
42+
else
43+
m_apiKey = parameters.value(QStringLiteral("googlemaps.apikey")).toString();
4144

4245
m_urlPrefix = QStringLiteral("https://maps.googleapis.com/maps/api/geocode/json");
4346

qgeoerror_messages.cpp

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/****************************************************************************
2+
**
3+
** Copyright (C) 2015 The Qt Company Ltd.
4+
** Contact: http://www.qt.io/licensing/
5+
**
6+
** This file is part of the QtLocation module of the Qt Toolkit.
7+
**
8+
** $QT_BEGIN_LICENSE:LGPL3$
9+
** Commercial License Usage
10+
** Licensees holding valid commercial Qt licenses may use this file in
11+
** accordance with the commercial license agreement provided with the
12+
** Software or, alternatively, in accordance with the terms contained in
13+
** a written agreement between you and The Qt Company. For licensing terms
14+
** and conditions see http://www.qt.io/terms-conditions. For further
15+
** information use the contact form at http://www.qt.io/contact-us.
16+
**
17+
** GNU Lesser General Public License Usage
18+
** Alternatively, this file may be used under the terms of the GNU Lesser
19+
** General Public License version 3 as published by the Free Software
20+
** Foundation and appearing in the file LICENSE.LGPLv3 included in the
21+
** packaging of this file. Please review the following information to
22+
** ensure the GNU Lesser General Public License version 3 requirements
23+
** will be met: https://www.gnu.org/licenses/lgpl.html.
24+
**
25+
** GNU General Public License Usage
26+
** Alternatively, this file may be used under the terms of the GNU
27+
** General Public License version 2.0 or later as published by the Free
28+
** Software Foundation and appearing in the file LICENSE.GPL included in
29+
** the packaging of this file. Please review the following information to
30+
** ensure the GNU General Public License version 2.0 requirements will be
31+
** met: http://www.gnu.org/licenses/gpl-2.0.html.
32+
**
33+
** $QT_END_LICENSE$
34+
**
35+
****************************************************************************/
36+
37+
#include "qgeoerror_messages.h"
38+
39+
QT_BEGIN_NAMESPACE
40+
41+
const char NOKIA_PLUGIN_CONTEXT_NAME[] = "QtLocationQML";
42+
const char MISSED_CREDENTIALS[] = QT_TRANSLATE_NOOP("QtLocationQML", "Qt Location requires app_id and token parameters.\nPlease register at https://developer.here.com/ to get your personal application credentials.");
43+
const char SAVING_PLACE_NOT_SUPPORTED[] = QT_TRANSLATE_NOOP("QtLocationQML", "Saving places is not supported.");
44+
const char REMOVING_PLACE_NOT_SUPPORTED[] = QT_TRANSLATE_NOOP("QtLocationQML", "Removing places is not supported.");
45+
const char SAVING_CATEGORY_NOT_SUPPORTED[] = QT_TRANSLATE_NOOP("QtLocationQML", "Saving categories is not supported.");
46+
const char REMOVING_CATEGORY_NOT_SUPPORTED[] = QT_TRANSLATE_NOOP("QtLocationQML", "Removing categories is not supported.");
47+
const char PARSE_ERROR[] = QT_TRANSLATE_NOOP("QtLocationQML", "Error parsing response.");
48+
const char NETWORK_ERROR[] = QT_TRANSLATE_NOOP("QtLocationQML", "Network error.");
49+
const char CANCEL_ERROR[] = QT_TRANSLATE_NOOP("QtLocationQML", "Request was canceled.");
50+
const char RESPONSE_NOT_RECOGNIZABLE[] = QT_TRANSLATE_NOOP("QtLocationQML", "The response from the service was not in a recognizable format.");
51+
52+
QT_END_NAMESPACE

qgeoerror_messages.h

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
/****************************************************************************
3+
**
4+
** Copyright (C) 2015 The Qt Company Ltd.
5+
** Contact: http://www.qt.io/licensing/
6+
**
7+
** This file is part of the QtLocation module of the Qt Toolkit.
8+
**
9+
** $QT_BEGIN_LICENSE:LGPL3$
10+
** Commercial License Usage
11+
** Licensees holding valid commercial Qt licenses may use this file in
12+
** accordance with the commercial license agreement provided with the
13+
** Software or, alternatively, in accordance with the terms contained in
14+
** a written agreement between you and The Qt Company. For licensing terms
15+
** and conditions see http://www.qt.io/terms-conditions. For further
16+
** information use the contact form at http://www.qt.io/contact-us.
17+
**
18+
** GNU Lesser General Public License Usage
19+
** Alternatively, this file may be used under the terms of the GNU Lesser
20+
** General Public License version 3 as published by the Free Software
21+
** Foundation and appearing in the file LICENSE.LGPLv3 included in the
22+
** packaging of this file. Please review the following information to
23+
** ensure the GNU Lesser General Public License version 3 requirements
24+
** will be met: https://www.gnu.org/licenses/lgpl.html.
25+
**
26+
** GNU General Public License Usage
27+
** Alternatively, this file may be used under the terms of the GNU
28+
** General Public License version 2.0 or later as published by the Free
29+
** Software Foundation and appearing in the file LICENSE.GPL included in
30+
** the packaging of this file. Please review the following information to
31+
** ensure the GNU General Public License version 2.0 requirements will be
32+
** met: http://www.gnu.org/licenses/gpl-2.0.html.
33+
**
34+
** $QT_END_LICENSE$
35+
**
36+
****************************************************************************/
37+
38+
#ifndef QGEOERROR_MESSAGES_H
39+
#define QGEOERROR_MESSAGES_H
40+
41+
#include <qglobal.h>
42+
43+
QT_BEGIN_NAMESPACE
44+
45+
extern const char NOKIA_PLUGIN_CONTEXT_NAME[];
46+
extern const char MISSED_CREDENTIALS[];
47+
extern const char SAVING_PLACE_NOT_SUPPORTED[];
48+
extern const char REMOVING_PLACE_NOT_SUPPORTED[];
49+
extern const char SAVING_CATEGORY_NOT_SUPPORTED[];
50+
extern const char REMOVING_CATEGORY_NOT_SUPPORTED[];
51+
extern const char PARSE_ERROR[];
52+
extern const char NETWORK_ERROR[];
53+
extern const char CANCEL_ERROR[];
54+
extern const char RESPONSE_NOT_RECOGNIZABLE[];
55+
56+
QT_END_NAMESPACE
57+
58+
#endif // QGEOERROR_MESSAGES_H

qgeoroutingmanagerenginegooglemaps.cpp

100644100755
+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ QGeoRoutingManagerEngineGooglemaps::QGeoRoutingManagerEngineGooglemaps(const QVa
1616
m_userAgent = "Qt Location based application";
1717

1818
m_urlPrefix = QStringLiteral("https://maps.googleapis.com/maps/api/directions/json");
19-
m_apiKey = parameters.value(QStringLiteral("googlemaps.route.apikey")).toString();
19+
if(parameters.contains(QStringLiteral("googlemaps.route.apikey")))
20+
m_apiKey = parameters.value(QStringLiteral("googlemaps.route.apikey")).toString();
21+
else
22+
m_apiKey = parameters.value(QStringLiteral("googlemaps.apikey")).toString();
2023

2124
*error = QGeoServiceProvider::NoError;
2225
errorString->clear();

qgeotiledmappingmanagerenginegooglemaps.cpp

100644100755
+20-21
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ QGeoTiledMappingManagerEngineGooglemaps::QGeoTiledMappingManagerEngineGooglemaps
2525
Q_UNUSED(errorString);
2626

2727
QGeoCameraCapabilities capabilities;
28-
2928
capabilities.setMinimumZoomLevel(0.0);
3029
capabilities.setMaximumZoomLevel(21.0);
3130

@@ -36,10 +35,10 @@ QGeoTiledMappingManagerEngineGooglemaps::QGeoTiledMappingManagerEngineGooglemaps
3635
setTileSize(QSize(tile, tile));
3736

3837
QList<QGeoMapType> types;
39-
types << QGeoMapType(QGeoMapType::StreetMap, tr("Street Map"), tr("Normal map view in daylight mode"), false, false, 1);
40-
types << QGeoMapType(QGeoMapType::SatelliteMapDay, tr("Satellite Map"), tr("Satellite map view in daylight mode"), false, false, 2);
41-
types << QGeoMapType(QGeoMapType::TerrainMap, tr("Terrain Map"), tr("Terrain map view in daylight mode"), false, false, 3);
42-
types << QGeoMapType(QGeoMapType::HybridMap, tr("Hybrid Map"), tr("Satellite map view with streets in daylight mode"), false, false, 4);
38+
types << QGeoMapType(QGeoMapType::StreetMap, tr("Road Map"), tr("Normal map view in daylight mode"), false, false, 1);
39+
types << QGeoMapType(QGeoMapType::SatelliteMapDay, tr("Satellite"), tr("Satellite map view in daylight mode"), false, false, 2);
40+
types << QGeoMapType(QGeoMapType::TerrainMap, tr("Terrain"), tr("Terrain map view in daylight mode"), false, false, 3);
41+
types << QGeoMapType(QGeoMapType::HybridMap, tr("Hybrid"), tr("Satellite map view with streets in daylight mode"), false, false, 4);
4342
setSupportedMapTypes(types);
4443

4544
QGeoTileFetcherGooglemaps *fetcher = new QGeoTileFetcherGooglemaps(parameters, this, tileSize());
@@ -54,28 +53,28 @@ QGeoTiledMappingManagerEngineGooglemaps::QGeoTiledMappingManagerEngineGooglemaps
5453
tileCache->setMaxDiskUsage(100 * 1024 * 1024);
5554
setTileCache(tileCache);
5655

57-
populateMapSchemes();
58-
*error = QGeoServiceProvider::NoError;
59-
errorString->clear();
56+
// populateMapSchemes();
57+
// *error = QGeoServiceProvider::NoError;
58+
// errorString->clear();
6059
}
6160

6261
QGeoTiledMappingManagerEngineGooglemaps::~QGeoTiledMappingManagerEngineGooglemaps()
6362
{
6463
}
6564

66-
void QGeoTiledMappingManagerEngineGooglemaps::populateMapSchemes()
67-
{
68-
m_mapSchemes[0] = QStringLiteral("roadmap");
69-
m_mapSchemes[1] = QStringLiteral("roadmap");
70-
m_mapSchemes[2] = QStringLiteral("satellite");
71-
m_mapSchemes[3] = QStringLiteral("terrain");
72-
m_mapSchemes[4] = QStringLiteral("hybrid");
73-
}
74-
75-
QString QGeoTiledMappingManagerEngineGooglemaps::getScheme(int mapId)
76-
{
77-
return m_mapSchemes[mapId];
78-
}
65+
//void QGeoTiledMappingManagerEngineGooglemaps::populateMapSchemes()
66+
//{
67+
// m_mapSchemes[0] = QStringLiteral("roadmap");
68+
// m_mapSchemes[1] = QStringLiteral("roadmap");
69+
// m_mapSchemes[2] = QStringLiteral("satellite");
70+
// m_mapSchemes[3] = QStringLiteral("terrain");
71+
// m_mapSchemes[4] = QStringLiteral("hybrid");
72+
//}
73+
74+
//QString QGeoTiledMappingManagerEngineGooglemaps::getScheme(int mapId)
75+
//{
76+
// return m_mapSchemes[mapId];
77+
//}
7978

8079
QGeoMap *QGeoTiledMappingManagerEngineGooglemaps::createMap()
8180
{

qgeotiledmappingmanagerenginegooglemaps.h

100644100755
+2-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ class QGeoTiledMappingManagerEngineGooglemaps : public QGeoTiledMappingManagerEn
3232

3333
private:
3434
void initialize();
35-
void populateMapSchemes();
35+
// void populateMapSchemes();
3636

37-
QHash<int, QString> m_mapSchemes;
37+
// QHash<int, QString> m_mapSchemes;
3838
QString m_cacheDirectory;
3939
};
4040

0 commit comments

Comments
 (0)