qgis导入在线地图网址

https://webst01.is.autonavi.com/appmaptile?style%3D6%26x%3D%7Bx%7D%26y%3D%7By%7D%26z%3D%7Bz%7D&zmax=18&zmin=0

type=xyz&url=http://www.google.cn/maps/vt?lyrs=s@820&gl=cn&x={x}&y={y}&z={z}

 

type=xyz&url=http://www.google.cn/maps/vt?lyrs=s@820&gl=cn&x={x}&y={y}&z={z}&zmax=18&zmin=0

 


type=xyz&url=http://www.google.cn/maps/vt?lyrs%3Ds@820%26gl%3Dcn%26x%3D%7Bx%7D%26y%3D%7By%7D%26z%3D%7Bz%7D&zmax=18&zmin=0

 

用utf8编码

 

使用下面代码加载在线地图,但是我遇到了一个奇怪的问题,

我是用3.4的版本,在win下正常,但是在Linux下,在线地图只显示一半,目前不知道问题在哪,有知道麻烦留言帮我解决一下,谢谢。

如下图:

linux下效果,只有北半球

qgis导入在线地图网址_第1张图片

 

win下效果,正常

qgis导入在线地图网址_第2张图片

 

addOpenSourceRasterLayer("type=xyz&url=http://www.google.cn/maps/vt?lyrs%3Ds@820%26gl%3Dcn%26x%3D%7Bx%7D%26y%3D%7By%7D%26z%3D%7Bz%7D&zmax=18&zmin=0", "Google Sat", "wms");

void QtGuiApplication1::addOpenSourceRasterLayer(const QString& url, const QString& basename, const QString& providerKey)
{
	//        rasterLyr = QgsRasterLayer("type=xyz&url=http://c.tile.openstreetmap.org / {z} / {x} / {y}.png", "OSM", "wms") 

	QgsRasterLayer *rasterLayer = 0;

	if (providerKey.isEmpty())
	{
		rasterLayer = new QgsRasterLayer(url, basename);
	}
	else
	{
		rasterLayer = new QgsRasterLayer(url, basename, providerKey);
	}

	if (!rasterLayer->isValid())
	{
		QMessageBox::critical(this, "error", "layer is invalid");
		return;
	}

	//QgsMapLayerRegistry::instance()->addMapLayer(rasterLayer);
	//QgsProject.instance()->addMapLayer(rasterLayer);
	//qgsProject = QgsProject::instance();
	qgsProject->addMapLayer(rasterLayer);
	//mapCanvasLayerSet.append(rasterLayer);
	layers.append(rasterLayer);
	mapCanvas->setExtent(rasterLayer->extent());
	mapCanvas->setLayers(layers);
	mapCanvas->setVisible(true);
	mapCanvas->freeze(false);
	mapCanvas->refresh();
}

 

当导入多个图层被覆盖后,可以设置图层的当前层数,来改变

    //layers.append(vecLayer);
    layers.insert(0, vecLayer);

你可能感兴趣的:(QT,QGIS)