欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

MFC之 MapWinGis叠加天地图瓦片地图

程序员文章站 2022-07-02 08:55:01
...

1、核心代码

/**************************************************************************************
 * Project: MapWindow Open Source (MapWinGis ActiveX control) 
 **************************************************************************************
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * (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.mozilla.org/mpl/ 
 * See the License for the specific language governing rights and limitations
 * under the License.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 ************************************************************************************** 
 * Contributor(s): 
 * (Open source contributors should list themselves and their modifications here). */
  
#pragma once
#include "BaseProvider.h"

/*
	BaseMap_layerId = "img_w";//获取影像地图(底图)
	ImageCNNote_layerId = "cia_w";//获取影像地图(中文注记)
	ImageENNote_layerId = "eia_w";//获取影像地图(英文注记)
	
	TerrainBaseMap_layerId = "ter_w";//获取地形图(底图)
	TerrainCNNote_layerId = "cta_w";//获取地形图(中文注记)
	TerrainENNote//暂无//获取地形图(英文注记)
	
	VectorBaseMap_layerId = "vec_c";//获取矢量图(底图)vec_w
	VectorCNNote_layerId = "cva_c";//获取矢量图(中文注记)cva_w
	VectorENNote_layerId = "eva_c";//获取矢量图(英文注记)eva_w

	TianDiImageBaseMap	= 39,
	TianDiCNNoteImageMap	= 40,
	TianDiENNoteImageMap	= 41,
	TianDiTerrainBaseMap	= 42,
	TianDiTerrainCNNoteMap	= 43,
	TianDiTerrainENNoteMap	= 44,
	TianDiVectorBasMap	= 45,
	TianDiVectorCNNoteMap	= 46,
	TianDiVectorENNoteMap	= 47,
	
	https://www.cnblogs.com/The-SEA/p/4364074.html
*/

class TianDiBaseProvider: public BaseProvider
{
protected:
	CString Styles;
public:
	TianDiBaseProvider() 
	{
		LanguageStr = "zh_cn";
		_refererUrl = "http://ditu.amap.com/";
		_licenseUrl = "https://mapwingis.codeplex.com/wikipage?title=baidutiles";
		int year = Utility::GetCurrentYear();
		_copyright.Format(L"Copyright @ %d, 天地图,All Rights Reserved", year);
		this->_projection = new MercatorProjection();
		this->_minZoom = 1;
		this->_maxZoom = 18;
		Styles = "img_w";
		_urlFormat = "http://t%d.tianditu.com/DataServer?T=%s&x=%d&y=%d&l=%d";
		//_urlFormat = "http://t%d.tianditu.cn/%s/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=vec&tileMatrixSet=c&TileMatrix=%d&TileRow=%d&TileCol=%d&style=default&format=tiles";
		//UrlFormat = "http://t3.tianditu.cn/vec_c/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=vec&tileMatrixSet=c&TileMatrix=10&TileRow=159&TileCol=828&style=default&format=tiles";
	}
	
	CString MakeTileImageUrl(CPoint &pos, int zoom)
	{
		CString s;
		int iServerNum = GetServerNum(pos, 8);
		s.Format(_urlFormat, iServerNum, Styles, pos.x, pos.y, zoom);
		//s.Format(_urlFormat, iServerNum, Styles, zoom, pos.y, pos.x);
		return s;
	}
};

class TianDiImageBaseMapProvider: public TianDiBaseProvider
{
public:
	TianDiImageBaseMapProvider() 
	{
		Id = tkTileProvider::TianDiImageBaseMap;
		Name = "TianDiImageBaseMaps";
		Styles = "img_w";
		_subProviders.push_back(this);
	}
};

class TianDiCNNoteImageMapProvider: public TianDiBaseProvider
{
public:
	TianDiCNNoteImageMapProvider() 
	{
		Id = tkTileProvider::TianDiCNNoteImageMap;
		Name = "TianDiCNNoteImageMaps";
		Styles = "cia_w";
		_subProviders.push_back(this);
	}
};

class TianDiENNoteImageMapProvider: public TianDiBaseProvider
{
public:
	TianDiENNoteImageMapProvider() 
	{
		Id = tkTileProvider::TianDiENNoteImageMap;
		Name = "TianDiENNoteImageMaps";
		Styles = "eia_w";
		_subProviders.push_back(this);
	}
};

class TianDiTerrainBaseMapProvider: public TianDiBaseProvider
{
public:
	TianDiTerrainBaseMapProvider() 
	{
		Id = tkTileProvider::TianDiTerrainBaseMap;
		Name = "TianDiTerrainBaseMaps";
		Styles = "ter_w";
		_subProviders.push_back(this);
	}
};

class TianDiTerrainCNNoteMapProvider: public TianDiBaseProvider
{
public:
	TianDiTerrainCNNoteMapProvider() 
	{
		Id = tkTileProvider::TianDiTerrainCNNoteMap;
		Name = "TianDiTerrainCNNoteMaps";
		Styles = "cta_w";
		_subProviders.push_back(this);
	}
};

class TianDiTerrainENNoteMapProvider: public TianDiBaseProvider
{
public:
	TianDiTerrainENNoteMapProvider() 
	{
		Id = tkTileProvider::TianDiTerrainENNoteMap;
		Name = "TianDiTerrainCNNoteMaps";
		Styles = "eta_w";
		_subProviders.push_back(this);
	}
};

class TianDiVectorBaseMapProvider: public TianDiBaseProvider
{
public:
	TianDiVectorBaseMapProvider() 
	{
		Id = tkTileProvider::TianDiVectorBaseMap;
		Name = "TianDiVectorBaseMaps";
		Styles = "vec_c";
		_subProviders.push_back(this);
	}
};

class TianDiVectorCNNoteMapProvider: public TianDiBaseProvider
{
public:
	TianDiVectorCNNoteMapProvider() 
	{
		Id = tkTileProvider::TianDiVectorCNNoteMap;
		Name = "TianDiVectorCNNoteMaps";
		Styles = "cva_c";
		_subProviders.push_back(this);
	}
};

class TianDiVectorENNoteMapProvider: public TianDiBaseProvider
{
public:
	TianDiVectorENNoteMapProvider() 
	{
		Id = tkTileProvider::TianDiVectorENNoteMap;
		Name = "TianDiVectorENNoteMaps";
		Styles = "eva_c";
		_subProviders.push_back(this);
	}
};

2、效果图

后期奉上,敬请关注..

上一篇: 天地图

下一篇: wireshark抓包的问题