-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Configure basemap style language sample #1688
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
39988ec
Adding configure basemap style language sample
har13205 4009a8b
Initializing basemapStyleParameters
har13205 edd0551
Update ArcGISRuntimeSDKQt_CppSamples/Maps/ConfigureBasemapStyleLangua…
har13205 71acdd2
Update ArcGISRuntimeSDKQt_CppSamples/Maps/ConfigureBasemapStyleLangua…
har13205 479515d
Update ArcGISRuntimeSDKQt_CppSamples/Maps/ConfigureBasemapStyleLangua…
har13205 50c5414
Update ArcGISRuntimeSDKQt_CppSamples/Maps/ConfigureBasemapStyleLangua…
har13205 0379821
Update ArcGISRuntimeSDKQt_CppSamples/Maps/ConfigureBasemapStyleLangua…
har13205 d9783d2
Update ArcGISRuntimeSDKQt_CppSamples/Maps/ConfigureBasemapStyleLangua…
har13205 3783d68
Update ArcGISRuntimeSDKQt_CppSamples/Maps/ConfigureBasemapStyleLangua…
har13205 a9a465c
Update ArcGISRuntimeSDKQt_CppSamples/Maps/ConfigureBasemapStyleLangua…
har13205 f64922c
Update ArcGISRuntimeSDKQt_CppSamples/Maps/ConfigureBasemapStyleLangua…
har13205 1769e6d
Changes as per PR comments
har13205 8d3364e
Update ArcGISRuntimeSDKQt_CppSamples/Maps/ConfigureBasemapStyleLangua…
har13205 41e07ec
Update ArcGISRuntimeSDKQt_CppSamples/Maps/ConfigureBasemapStyleLangua…
har13205 5d36cdf
Changes as per PR comments
har13205 9f52d51
Update ArcGISRuntimeSDKQt_CppSamples/Maps/ConfigureBasemapStyleLangua…
har13205 0b36d5b
Update ArcGISRuntimeSDKQt_CppSamples/Maps/ConfigureBasemapStyleLangua…
har13205 cd68518
Update ArcGISRuntimeSDKQt_CppSamples/Maps/ConfigureBasemapStyleLangua…
har13205 c4d12b1
Update ArcGISRuntimeSDKQt_CppSamples/Maps/ConfigureBasemapStyleLangua…
har13205 0860c3d
Changes as per PR comments
har13205 7a6a3f5
Changes as per PR comments
har13205 dbc50f4
Adding comment for onCurrentTextChanged
har13205 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
104 changes: 104 additions & 0 deletions
104
...timeSDKQt_CppSamples/Maps/ConfigureBasemapStyleLanguage/ConfigureBasemapStyleLanguage.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// [WriteFile Name=ConfigureBasemapStyleLanguage, Category=Maps] | ||
// [Legal] | ||
// Copyright 2024 Esri. | ||
|
||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// [Legal] | ||
|
||
#ifdef PCH_BUILD | ||
#include "pch.hpp" | ||
#endif // PCH_BUILD | ||
|
||
#include "Basemap.h" | ||
#include "BasemapStyleParameters.h" | ||
#include "ConfigureBasemapStyleLanguage.h" | ||
#include "Map.h" | ||
#include "MapQuickView.h" | ||
#include "MapTypes.h" | ||
#include "Point.h" | ||
#include "SpatialReference.h" | ||
#include "Viewpoint.h" | ||
|
||
#include <QFuture> | ||
|
||
using namespace Esri::ArcGISRuntime; | ||
|
||
ConfigureBasemapStyleLanguage::ConfigureBasemapStyleLanguage(QObject* parent /* = nullptr */) : | ||
QObject(parent), | ||
m_map(new Map(SpatialReference::webMercator(), this)), | ||
m_basemapStyleParameters(new BasemapStyleParameters(this)) | ||
{ | ||
} | ||
|
||
ConfigureBasemapStyleLanguage::~ConfigureBasemapStyleLanguage() = default; | ||
|
||
void ConfigureBasemapStyleLanguage::init() | ||
{ | ||
// Register the map view for QML | ||
qmlRegisterType<MapQuickView>("Esri.Samples", 1, 0, "MapView"); | ||
qmlRegisterType<ConfigureBasemapStyleLanguage>("Esri.Samples", 1, 0, "ConfigureBasemapStyleLanguageSample"); | ||
} | ||
|
||
MapQuickView* ConfigureBasemapStyleLanguage::mapView() const | ||
{ | ||
return m_mapView; | ||
} | ||
|
||
// Set the view (created in QML) | ||
void ConfigureBasemapStyleLanguage::setMapView(MapQuickView* mapView) | ||
{ | ||
if (!mapView || mapView == m_mapView) | ||
return; | ||
|
||
m_mapView = mapView; | ||
m_mapView->setMap(m_map); | ||
|
||
const Point point(3144804, 4904598); | ||
|
||
// Create a Viewpoint object with the created Point and a scale of 10000000 | ||
const Viewpoint viewpoint(point, 10000000); | ||
|
||
// Set the viewpoint for the mapView | ||
mapView->setViewpointAsync(viewpoint); | ||
|
||
emit mapViewChanged(); | ||
} | ||
|
||
// Set new basemap language based on the parameters selected | ||
void ConfigureBasemapStyleLanguage::setNewBasemapLanguage(bool global, const QString& language) | ||
{ | ||
m_basemapStyleParameters->setLanguageStrategy(global ? BasemapStyleLanguageStrategy::Global : BasemapStyleLanguageStrategy::Local); | ||
|
||
// A SpecificLanguage setting overrides the LanguageStrategy settings | ||
if (language == "none") | ||
{ | ||
m_basemapStyleParameters->setSpecificLanguage(""); | ||
} | ||
else if (language == "Bulgarian") | ||
{ | ||
m_basemapStyleParameters->setSpecificLanguage("bg"); | ||
} | ||
else if (language == "Greek") | ||
{ | ||
m_basemapStyleParameters->setSpecificLanguage("el"); | ||
} | ||
else if (language == "Turkish") | ||
{ | ||
m_basemapStyleParameters->setSpecificLanguage("tr"); | ||
} | ||
|
||
if (m_basemap) | ||
m_basemap->deleteLater(); | ||
|
||
m_basemap = new Basemap(BasemapStyle::OsmLightGray, m_basemapStyleParameters, this); | ||
m_map->setBasemap(m_basemap); | ||
} |
57 changes: 57 additions & 0 deletions
57
...untimeSDKQt_CppSamples/Maps/ConfigureBasemapStyleLanguage/ConfigureBasemapStyleLanguage.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// [WriteFile Name=ConfigureBasemapStyleLanguage, Category=Maps] | ||
// [Legal] | ||
// Copyright 2024 Esri. | ||
|
||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// [Legal] | ||
|
||
#ifndef CONFIGUREBASEMAPSTYLELANGUAGE_H | ||
#define CONFIGUREBASEMAPSTYLELANGUAGE_H | ||
|
||
namespace Esri::ArcGISRuntime { | ||
class Basemap; | ||
class BasemapStyleParameters; | ||
class Map; | ||
class MapQuickView; | ||
} | ||
|
||
#include <QObject> | ||
|
||
Q_MOC_INCLUDE("MapQuickView.h"); | ||
|
||
class ConfigureBasemapStyleLanguage : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
Q_PROPERTY(Esri::ArcGISRuntime::MapQuickView* mapView READ mapView WRITE setMapView NOTIFY mapViewChanged) | ||
|
||
public: | ||
explicit ConfigureBasemapStyleLanguage(QObject* parent = nullptr); | ||
~ConfigureBasemapStyleLanguage() override; | ||
|
||
static void init(); | ||
Q_INVOKABLE void setNewBasemapLanguage(bool global, const QString& language); | ||
|
||
signals: | ||
void mapViewChanged(); | ||
|
||
private: | ||
Esri::ArcGISRuntime::MapQuickView* mapView() const; | ||
void setMapView(Esri::ArcGISRuntime::MapQuickView* mapView); | ||
|
||
Esri::ArcGISRuntime::Map* m_map = nullptr; | ||
Esri::ArcGISRuntime::MapQuickView* m_mapView = nullptr; | ||
Esri::ArcGISRuntime::BasemapStyleParameters* m_basemapStyleParameters = nullptr; | ||
Esri::ArcGISRuntime::Basemap* m_basemap = nullptr; | ||
}; | ||
|
||
#endif // CONFIGUREBASEMAPSTYLELANGUAGE_H |
64 changes: 64 additions & 0 deletions
64
...timeSDKQt_CppSamples/Maps/ConfigureBasemapStyleLanguage/ConfigureBasemapStyleLanguage.pro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#------------------------------------------------- | ||
# Copyright 2024 Esri. | ||
|
||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
#------------------------------------------------- | ||
|
||
mac { | ||
cache() | ||
} | ||
|
||
#------------------------------------------------------------------------------- | ||
|
||
CONFIG += c++17 | ||
|
||
# additional modules are pulled in via arcgisruntime.pri | ||
QT += opengl qml quick | ||
|
||
TEMPLATE = app | ||
TARGET = ConfigureBasemapStyleLanguage | ||
|
||
ARCGIS_RUNTIME_VERSION = 200.4.0 | ||
include($$PWD/arcgisruntime.pri) | ||
|
||
#------------------------------------------------------------------------------- | ||
|
||
HEADERS += \ | ||
ConfigureBasemapStyleLanguage.h | ||
|
||
SOURCES += \ | ||
main.cpp \ | ||
ConfigureBasemapStyleLanguage.cpp | ||
|
||
RESOURCES += ConfigureBasemapStyleLanguage.qrc | ||
|
||
#------------------------------------------------------------------------------- | ||
|
||
win32 { | ||
LIBS += \ | ||
Ole32.lib | ||
} | ||
|
||
ios { | ||
INCLUDEPATH += $$PWD | ||
DEPENDPATH += $$PWD | ||
|
||
OTHER_FILES += \ | ||
$$PWD/Info.plist | ||
|
||
QMAKE_INFO_PLIST = $$PWD/Info.plist | ||
} | ||
|
||
android { | ||
INCLUDEPATH += $$PWD | ||
DEPENDPATH += $$PWD | ||
} |
130 changes: 130 additions & 0 deletions
130
...timeSDKQt_CppSamples/Maps/ConfigureBasemapStyleLanguage/ConfigureBasemapStyleLanguage.qml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
// [WriteFile Name=ConfigureBasemapStyleLanguage, Category=Maps] | ||
// [Legal] | ||
// Copyright 2024 Esri. | ||
|
||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// [Legal] | ||
|
||
import QtQuick | ||
import QtQuick.Controls | ||
import Esri.Samples | ||
|
||
Item { | ||
|
||
// add a mapView component | ||
MapView { | ||
id: view | ||
anchors.fill: parent | ||
|
||
Component.onCompleted: { | ||
// Set the focus on MapView to initially enable keyboard navigation | ||
forceActiveFocus(); | ||
} | ||
} | ||
|
||
// Declare the C++ instance which creates the map etc. and supply the view | ||
ConfigureBasemapStyleLanguageSample { | ||
id: model | ||
mapView: view | ||
} | ||
|
||
Rectangle { | ||
id: rectangle | ||
anchors { | ||
right: parent.right | ||
top: parent.top | ||
margins: 15 | ||
} | ||
width: column.width | ||
height: column.height | ||
color: Qt.rgba(0, 0, 0, 0.5) | ||
border { | ||
color: "black" | ||
width: 1 | ||
} | ||
opacity: 0.9 | ||
|
||
Column { | ||
id: column | ||
padding: 10 | ||
spacing: 5 | ||
width: 300 | ||
|
||
Column { | ||
id:languageStrategy | ||
spacing: 5 | ||
|
||
Text { | ||
text: "Set Language Strategy:" | ||
font.bold: true | ||
color: "white" | ||
} | ||
|
||
Row { | ||
RadioButton { | ||
id: globalButton | ||
onCheckedChanged: { | ||
model.setNewBasemapLanguage(globalButton.checked, comboBox.currentText); | ||
localButton.checked = !globalButton.checked | ||
} | ||
enabled: comboBox.currentText == "none" | ||
} | ||
|
||
Text { | ||
id: globalText | ||
text: "Global" | ||
height: globalButton.height | ||
verticalAlignment: Text.AlignVCenter | ||
color: "white" | ||
} | ||
} | ||
|
||
Row { | ||
RadioButton { | ||
id: localButton | ||
checked: true | ||
onCheckedChanged: { | ||
model.setNewBasemapLanguage(globalButton.checked, comboBox.currentText); | ||
globalButton.checked = !localButton.checked | ||
} | ||
enabled: comboBox.currentText == "none" | ||
} | ||
Text { | ||
id: localText | ||
text: "Local" | ||
height: localButton.height | ||
verticalAlignment: Text.AlignVCenter | ||
color: "white" | ||
} | ||
} | ||
|
||
} | ||
|
||
Column { | ||
id:specificLanguage | ||
|
||
Text { | ||
text: "Set Specific Language:" | ||
font.bold: true | ||
color: "white" | ||
} | ||
|
||
ComboBox { | ||
id: comboBox | ||
model: ["none" , "Bulgarian", "Greek", "Turkish"] | ||
// onCurrentTextChanged executes when the text is changed and also initially on loading the sample | ||
onCurrentTextChanged: model.setNewBasemapLanguage(globalButton.checked, comboBox.currentText); | ||
} | ||
} | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...timeSDKQt_CppSamples/Maps/ConfigureBasemapStyleLanguage/ConfigureBasemapStyleLanguage.qrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<RCC> | ||
<qresource prefix="/Samples/Maps/ConfigureBasemapStyleLanguage"> | ||
<file alias="sample.json">README.metadata.json</file> | ||
<file>ConfigureBasemapStyleLanguage.qml</file> | ||
<file>ConfigureBasemapStyleLanguage.h</file> | ||
<file>ConfigureBasemapStyleLanguage.cpp</file> | ||
<file>main.qml</file> | ||
<file>screenshot.png</file> | ||
<file>README.md</file> | ||
</qresource> | ||
</RCC> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per our offline discussion, I think this should be more intentional. It seems this executes when the code first loads, but it's unclear from looking at the c++ code how any basemap was loaded. I think the code should be more intentional about how the initial basemap is being set.
When I reviewed the latest code, I assumed no basemap at all was set, because that's what is happening on the C++ side via the constructor.