ArcGIS Runtime SDK for Qt

Web tiled layer

Loading

Code

#include "Web_Tiled_Layer.h"

#include "Map.h"
#include "MapQuickView.h"
#include "Basemap.h"
#include "WebTiledLayer.h"
#include "Viewpoint.h"
#include "Point.h"

#include <QStringList>

using namespace Esri::ArcGISRuntime;

Web_Tiled_Layer::Web_Tiled_Layer(QQuickItem* parent /* = nullptr */):
  QQuickItem(parent)
{
}

Web_Tiled_Layer::~Web_Tiled_Layer()
{
}

void Web_Tiled_Layer::init()
{
  qmlRegisterType<MapQuickView>("Esri.Samples", 1, 0, "MapView");
  qmlRegisterType<Web_Tiled_Layer>("Esri.Samples", 1, 0, "Web_Tiled_LayerSample");
}

void Web_Tiled_Layer::componentComplete()
{
  QQuickItem::componentComplete();

  // find QML MapView component
  m_mapView = findChild<MapQuickView*>("mapView");

  // Set up the tiled layer parameters
  const QString templateUrl = "http://{subDomain}.tile.stamen.com/terrain/{level}/{col}/{row}.png";
  const QStringList subDomains = QStringList() << "a" << "b" << "c" << "d";
  const QString attributionText = "Map tiles by <a href=\"http://stamen.com\">Stamen Design</a>, "
                                  "under <a href=\"http://creativecommons.org/licenses/by/3.0\">CC BY 3.0</a>. "
                                  "Data by <a href=\"http://openstreetmap.org\">OpenStreetMap</a>, "
                                  "under <a href=\"http://www.openstreetmap.org/copyright\">ODbL</a>.";

  // Create the WebTiledLayer with a template URL, sub domains, and copyright information
  WebTiledLayer* webTiledLayer = new WebTiledLayer(templateUrl, subDomains, this);
  webTiledLayer->setAttribution(attributionText);

  // Create a basemap from the WebTiledLayer
  Basemap* basemap = new Basemap(webTiledLayer, this);

  // Create a map using the WebTiledLayer basemap
  m_map = new Map(basemap, this);

  // Set an initial viewpoint
  Point pt(-13167861.0, 4382202.0, SpatialReference::webMercator());
  Viewpoint vp(pt, 50000.0);
  m_map->setInitialViewpoint(vp);

  // Set map to map view
  m_mapView->setMap(m_map);
}


In this topic
  1. Code