public abstract class AbstractTileLayerView
extends View
抽象图层视图,作为地图视图的子项添加到 MapView
中显示。
限定符和类型 | 字段和说明 |
---|---|
protected boolean |
addToNetworkDownload
瓦片是否使用网络下载,默认为true,离线图层可以设置为false,暂时不对外公开
|
protected Context |
context
Activity的上下文。
|
protected CoordinateReferenceSystem |
crs
用户设置坐标参考系。
|
protected java.lang.String |
curMapUrl
动态图层的发布地址url,即地图服务根地址,动态图层必设。
|
protected double |
dpi
地图默认分辨率(米每像素)和比例尺的乘积,跟dpi相关的一个运算值。
|
protected boolean |
isGCSLayer
图层是否为地理坐标系图层。
|
protected boolean |
isLayerInited
图层是否初始化完成。
|
protected BoundingBox |
layerBounds
用户设置图层的地理范围。
|
protected java.lang.String |
layerCacheFileName
用户设置图层的缓存文件名称,用于sd卡缓存。
|
protected java.lang.String |
layerName
图层的名字标签。
|
protected MapView |
mapView
当图层加入到mapView中时初始化。
|
protected Projection |
projection
工具类负责屏幕像素坐标与地理坐标的相互转化。
|
protected double[] |
resolutions
用户设置固定分辨率数组。
|
protected int |
tileCount
瓦片数量。
|
protected int |
totalTileCount
瓦片数量总和。
|
protected boolean |
visible
图层是否可见。
|
protected double[] |
visibleScales
用户设置固定比例尺数组。
|
protected int |
zoomLevel
用户设置地图缩放级别。
|
构造器和说明 |
---|
AbstractTileLayerView(Context context)
构造函数。
|
AbstractTileLayerView(Context context, AttributeSet attrs)
构造函数。
|
AbstractTileLayerView(Context context, AttributeSet attrs, int defStyle)
构造函数。
|
限定符和类型 | 方法和说明 |
---|---|
void |
asyncGetTilesFromCache()
异步去读取缓存数据,读取完毕刷新地图。
|
protected Tile |
buildTile(int x, int y, int zoom)
构造瓦片对象。
|
void |
clearCache(boolean clearServerCache)
清除客户端本地缓存。
|
void |
destroy()
销毁当前 LayerView 对象,退出前调用。
|
BoundingBox |
getBounds()
返回图层的地理范围。
|
CoordinateReferenceSystem |
getCRS()
获取当前图层的坐标参考系。
|
protected MapView |
getMapView()
获取MapView容器。
|
protected int |
getResolutionIndex()
获取当前层级的分辨率索引。
|
double[] |
getResolutions()
获取图层的分辨率数组。
|
double[] |
getScales()
获取图层显示时的固定比例尺数组。
|
protected com.supermap.android.maps.TileCacher |
getTileCacher()
获取android端瓦片的缓存。
|
java.lang.String |
getURL()
获取MapView中当前图层的 url 地址。
|
protected int |
getZoomLevel()
获取图层的缩放级别。
|
protected void |
initProjection()
初始化投影转换和坐标转化工具类Projection。
|
abstract void |
initTileContext(Tile tile)
初始化tile瓦片,具体继承类实现该接口。
|
protected boolean |
isGCSLayer()
返回是否为地理坐标系图层。
|
boolean |
isInitialized()
检查当前图层是否已经初始化完成。
|
boolean |
isVisible()
返回当前图层是否可见。
|
protected void |
onDraw(Canvas canvas)
主绘制方法。
|
void |
setCRS(CoordinateReferenceSystem crs)
设置坐标参考系类对象,用于支持动态投影。
|
void |
setLayerCacheFileName(java.lang.String cacheFileName)
设置图层的缓存文件名称,用于在sd卡中看到该图层的缓存文件夹
|
void |
setOpaqueRate(int PaintAlpha)
返回图层当前比例尺。
|
void |
setURL(java.lang.String mapUrl)
设置当前地图的 url,注意 url 不能进行任何编码。
|
void |
setVisible(boolean visible)
设置当前图层是否可见。
|
protected boolean |
validateZoomLevel(int zoom)
判断图层缩放级别是否合法。
|
protected Context context
Activity的上下文。
protected int totalTileCount
瓦片数量总和。
protected int tileCount
瓦片数量。
protected boolean visible
图层是否可见。默认为true,图层可见。
protected boolean isLayerInited
图层是否初始化完成。默认为false。
protected boolean isGCSLayer
图层是否为地理坐标系图层。默认为true。
protected java.lang.String curMapUrl
动态图层的发布地址url,即地图服务根地址,动态图层必设。
protected java.lang.String layerName
图层的名字标签。
protected java.lang.String layerCacheFileName
用户设置图层的缓存文件名称,用于sd卡缓存。
protected MapView mapView
当图层加入到mapView中时初始化。
protected double[] visibleScales
用户设置固定比例尺数组。
protected double[] resolutions
用户设置固定分辨率数组。
protected CoordinateReferenceSystem crs
用户设置坐标参考系。
protected BoundingBox layerBounds
用户设置图层的地理范围。
protected int zoomLevel
用户设置地图缩放级别。
protected Projection projection
工具类负责屏幕像素坐标与地理坐标的相互转化。
protected double dpi
地图默认分辨率(米每像素)和比例尺的乘积,跟dpi相关的一个运算值。
protected boolean addToNetworkDownload
瓦片是否使用网络下载,默认为true,离线图层可以设置为false,暂时不对外公开
public AbstractTileLayerView(Context context)
构造函数。
context
- Activity的上下文。public AbstractTileLayerView(Context context, AttributeSet attrs)
构造函数。
context
- Activity的上下文。attrs
- 属性信息。public AbstractTileLayerView(Context context, AttributeSet attrs, int defStyle)
构造函数。
context
- Activity的上下文。attrs
- 属性信息。defStyle
- 风格标识。protected void initProjection()
初始化投影转换和坐标转化工具类Projection。 其中ProjectionUtil 对象需要 mapView 的范围信息,所以添加初始化完成的图层后调用。
protected void onDraw(Canvas canvas)
主绘制方法。
canvas
- 待绘制的画布protected int getResolutionIndex()
获取当前层级的分辨率索引。
protected int getZoomLevel()
获取图层的缩放级别。
protected com.supermap.android.maps.TileCacher getTileCacher()
获取android端瓦片的缓存。
protected Tile buildTile(int x, int y, int zoom)
构造瓦片对象。
x
- 相对于屏幕中心点为原点的x坐标。y
- 相对于屏幕中心点为原点的y坐标。zoom
- 当前缩放层级。public abstract void initTileContext(Tile tile)
初始化tile瓦片,具体继承类实现该接口。即可以根据需要给瓦片设置请求瓦片的url、设置透明值、设置比例尺、设置瓦片所属的坐标系的epsgcode、设置瓦片内容的字节数组、设置瓦片内容的Bitmap对象。
tile
- 通过构造函数构建的瓦片对象,其初始化好了瓦片的列号x、行号y、缩放层级,地图图层名以及瓦片左上对应的像素坐标(px,py)。public void asyncGetTilesFromCache()
异步去读取缓存数据,读取完毕刷新地图。使用场景:当初始化完当前屏幕所需的瓦片后,根据已知瓦片,去异步读取离线数据缓存,保证不阻塞主线程 子类根据需要扩展实现,达到预期的效果,结合initTileContext(在其中保存所有初始化完成的瓦片list)接口使用,asyncGetTilesFromCache根据list异步读取瓦片缓存
public void clearCache(boolean clearServerCache)
清除客户端本地缓存。
clearServerCache
-public void destroy()
销毁当前 LayerView 对象,退出前调用。
public void setURL(java.lang.String mapUrl)
设置当前地图的 url,注意 url 不能进行任何编码。
mapUrl
- 地图服务的 url。public void setCRS(CoordinateReferenceSystem crs)
具体实现类最好重写该接口,如动态图层需要发送新请求获取投影后的地图状态。 而云图层就不支持动态投影即不支持设置,该接口需要抛出异常警告。
crs
-public java.lang.String getURL()
public double[] getScales()
获取图层显示时的固定比例尺数组。
public double[] getResolutions()
获取图层的分辨率数组。
public void setVisible(boolean visible)
设置当前图层是否可见。
visible
- 当前图层是否可见。public boolean isVisible()
返回当前图层是否可见。
public CoordinateReferenceSystem getCRS()
获取当前图层的坐标参考系。
public void setLayerCacheFileName(java.lang.String cacheFileName)
设置图层的缓存文件名称,用于在sd卡中看到该图层的缓存文件夹
cacheFileName
-public boolean isInitialized()
检查当前图层是否已经初始化完成。
protected boolean validateZoomLevel(int zoom)
判断图层缩放级别是否合法。
zoom
- 缩放级别。protected MapView getMapView()
获取MapView容器。
protected boolean isGCSLayer()
返回是否为地理坐标系图层。
public BoundingBox getBounds()
返回图层的地理范围。
public void setOpaqueRate(int PaintAlpha)
返回图层当前比例尺。