Appearance
覆盖物
所有覆盖物通过 MapController.addXxx(XxxOptions) 添加,返回对应对象用于后续属性更新。Options 类采用链式 builder 风格。map.clear() 清除全部覆盖物。
Marker
com.sfmap.api.maps.model.Marker
Marker 点标记。由 MapController.addMarker(MarkerOptions) 返回。
| 方法 | 说明 |
|---|---|
LatLng getPosition() / void setPosition(LatLng position) | 位置 |
void setPositionByPixels(int x, int y) | 通过屏幕像素定位 |
String getTitle() / void setTitle(String title) | 标题 |
String getSnippet() / void setSnippet(String snippet) | 副标题 |
void setIcon(BitmapDescriptor icon) | 设置图标 |
ArrayList<BitmapDescriptor> getIcons() / void setIcons(ArrayList<BitmapDescriptor> icons) | 多图标(帧动画) |
int getPeriod() / void setPeriod(int period) | 帧动画周期 |
float getAnchorU() / float getAnchorV() / void setAnchor(float u, float v) | 锚点 |
boolean isDraggable() / void setDraggable(boolean draggable) | 是否可拖拽 |
boolean isInfoWindowEnable() / void setInfoWindowEnable(boolean enable) | 点击是否自动弹出 InfoWindow |
boolean isVisible() / void setVisible(boolean visible) | 可见性 |
boolean isFlat() / void setFlat(boolean flat) | 是否平贴地图 |
float getRotateAngle() / void setRotateAngle(float rotateAngle) | 旋转角度 |
void setToTop() | 置于所有 marker 最上层 |
float getZIndex() / void setZIndex(float zIndex) | 层级 |
Object getObject() / void setObject(Object object) | 附加业务对象 |
void showInfoWindow() / void hideInfoWindow() / boolean isInfoWindowShown() | InfoWindow 显隐 |
void destroy() / void remove() | 销毁/移除 |
String getId() | 获取 id |
MarkerOptions
| 方法 | 说明 |
|---|---|
position(LatLng position) | 位置 |
icon(BitmapDescriptor icon) | 单图标 |
icons(ArrayList<BitmapDescriptor> icons) | 多图标 |
period(int period) | 帧动画周期 |
anchor(float u, float v) | 锚点 |
title(String title) | 标题 |
snippet(String snippet) | 副标题 |
draggable(boolean draggable) | 可拖拽 |
visible(boolean visible) | 可见性 |
flat(boolean flat) | 是否平贴 |
infoWindowEnable(boolean enable) | 点击弹 InfoWindow(默认 true) |
zIndex(float zIndex) | 层级 |
perspective(boolean perspective) | 透视 |
setAddByAnimation(boolean addByAnimation) | 动画添加 |
Polyline
com.sfmap.api.maps.model.Polyline
多段线。由 MapController.addPolyline(PolylineOptions) 返回。
| 方法 | 说明 |
|---|---|
List<LatLng> getPoints() / void setPoints(List<LatLng> points) | 点列表 |
void addPoint(LatLng point) | 追加一个点 |
int getColor() / void setColor(int color) | 颜色 |
float getWidth() / void setWidth(float width) | 宽度 |
void setGeodesic(boolean geodesic) / boolean isGeodesic() | 是否大地曲线 |
void setDottedLine(boolean dotted) / boolean isDottedLine() | 虚线 |
void setZIndex(float zIndex) / float getZIndex() | 层级 |
void setVisible(boolean visible) / boolean isVisible() | 可见性 |
void setTransparency(float transparency) / float getTransparency() | 透明度 |
LatLng getNearestLatLng(LatLng latLng) | 离指定点最近的线上的点 |
void setMultiLine(List<List<LatLng>> multiLines) / List<List<LatLng>> getMultiLines() | 多线段 |
void setUseTexture(boolean useTexture) / boolean isUseTexture() | 纹理开关 |
void setCustomTexture(BitmapDescriptor texture) | 自定义纹理 |
void remove() / String getId() | 移除/id |
PolylineOptions
常量(内置导航纹理 ID):BUILTIN_TEXTURE_ID_NAVIGATION_LINE_PASSED=67000、_UNKNOWN=67001、_SMOOTH=67002、_SLOW=67003、_BLOCK=67004、_STANDSTILL=67005(及对应 _UNFOCUSED 后缀 67006-67010)。
| 方法 | 说明 |
|---|---|
add(LatLng point) / add(LatLng... points) / addAll(Iterable<LatLng> points) | 添加点 |
width(float width) | 宽度 |
color(int color) | 颜色 |
colorValues(List<Integer> colors) | 多色渐变色值 |
useGradient(boolean paramBoolean) | 是否渐变 |
zIndex(float zIndex) | 层级 |
visible(boolean isVisible) | 可见性 |
geodesic(boolean isGeodesic) | 大地曲线 |
setDottedLine(boolean isDottedLine) | 虚线 |
setUseTexture(boolean useTexture) | 纹理开关 |
setCustomTexture(BitmapDescriptor customTexture) | 自定义纹理 |
setCustomTextureList(List<BitmapDescriptor> list) | 纹理列表 |
setCustomTextureIndex(List<Integer> list) | 纹理索引 |
setTexturePixelLength(int len) | 纹理像素长度 |
setBuiltinTextureIndexList(List<Integer> list) | 内置纹理索引列表 |
setMultiLine(List<List<LatLng>> multiLines) | 多线段 |
geoMultiLine(List<List<int[]>> geoMultiLines) | 坐标对多线段 |
Polygon
com.sfmap.api.maps.model.Polygon
多边形。由 MapController.addPolygon(PolygonOptions) 返回。
| 方法 | 说明 |
|---|---|
List<LatLng> getPoints() / void setPoints(List<LatLng> points) | 顶点列表 |
int getFillColor() / void setFillColor(int color) | 填充色 |
int getStrokeColor() / void setStrokeColor(int color) | 边框色 |
float getStrokeWidth() / void setStrokeWidth(float strokeWidth) | 边框宽 |
void setZIndex(float zIndex) / float getZIndex() | 层级 |
void setVisible(boolean visible) / boolean isVisible() | 可见性 |
boolean contains(LatLng point) | 射线法判断点是否在多边形内 |
void remove() / String getId() | 移除/id |
PolygonOptions
| 方法 | 说明 |
|---|---|
add(LatLng point) / add(LatLng... points) / addAll(Iterable<LatLng> points) | 添加顶点 |
addHole(List<LatLng> hole) | 添加镂空多边形 |
strokeWidth(float width) | 边框宽 |
strokeColor(int color) | 边框色 |
fillColor(int color) | 填充色 |
zIndex(float zIndex) | 层级 |
visible(boolean visible) | 可见性 |
Circle
com.sfmap.api.maps.model.Circle
圆形。由 MapController.addCircle(CircleOptions) 返回。
| 方法 | 说明 |
|---|---|
LatLng getCenter() / void setCenter(LatLng center) | 圆心 |
double getRadius() / void setRadius(double radius) | 半径(米) |
float getStrokeWidth() / void setStrokeWidth(float strokeWidth) | 边框宽 |
int getStrokeColor() / void setStrokeColor(int color) | 边框色 |
int getFillColor() / void setFillColor(int color) | 填充色 |
void setZIndex(float zIndex) / float getZIndex() | 层级 |
void setVisible(boolean visible) / boolean isVisible() | 可见性 |
boolean contains(LatLng latLng) | 判断点是否在圆内(Haversine 距离) |
void remove() / String getId() | 移除/id |
CircleOptions
| 方法 | 说明 |
|---|---|
center(LatLng point) | 圆心 |
radius(double radius) | 半径 |
strokeWidth(float width) | 边框宽 |
strokeColor(int color) | 边框色 |
fillColor(int color) | 填充色 |
zIndex(float zIndex) | 层级 |
visible(boolean visible) | 可见性 |
Arc
com.sfmap.api.maps.model.Arc
弧线。由 MapController.addArc(ArcOptions) 返回。由三点(起点/途经点/终点)定圆采样生成。
| 方法 | 说明 |
|---|---|
float getStrokeWidth() / void setStrokeWidth(float w) | 线宽 |
int getStrokeColor() / void setStrokeColor(int c) | 颜色 |
boolean isVisible() / void setVisible(boolean v) | 可见性 |
float getZIndex() / void setZIndex(float z) | 层级 |
void remove() / String getId() | 移除/id |
ArcOptions
| 方法 | 说明 |
|---|---|
add(LatLng... points) | 依次添加起点、中间控制点、终点 |
start(LatLng startPoint) | 起点 |
end(LatLng endPoint) | 终点 |
point(LatLng point) | 控制点 |
strokeWidth(float width) | 线宽 |
strokeColor(int color) | 颜色 |
zIndex(float zIndex) | 层级 |
visible(boolean visible) | 可见性 |
Text
com.sfmap.api.maps.model.Text
文字覆盖物。由 MapController.addText(TextOptions) 返回。
| 方法 | 说明 |
|---|---|
String getText() / void setText(String text) | 文字内容 |
LatLng getPosition() / void setPosition(LatLng position) | 位置 |
int getFontColor() / void setFontColor(int fontColor) | 字体颜色 |
int getBackgroundColor() / void setBackgroundColor(int backgroundColor) | 背景色 |
int getFontSize() / void setFontSize(int fontSize) | 字号 |
float getRotateAngle() / void setRotateAngle(float rotateAngle) | 旋转角度 |
int getAlign() / void setAlign(int align) | 对齐方式(ALIGN_*) |
float getZIndex() / void setZIndex(float zIndex) | 层级 |
boolean isVisible() / void setVisible(boolean visible) | 可见性 |
void remove() / String getId() | 移除/id |
TextOptions
常量(对齐方式):
| 常量 | 值 | 说明 |
|---|---|---|
ALIGN_CENTER | 0 | 居中(默认) |
ALIGN_LEFT | 1 | 左对齐 |
ALIGN_RIGHT | 2 | 右对齐 |
ALIGN_TOP | 3 | 顶部对齐 |
ALIGN_BOTTOM | 4 | 底部对齐 |
ALIGN_TOP_LEFT | 5 | 左上对齐 |
ALIGN_TOP_RIGHT | 6 | 右上对齐 |
ALIGN_BOTTOM_LEFT | 7 | 左下对齐 |
ALIGN_BOTTOM_RIGHT | 8 | 右下对齐 |
| 方法 | 说明 |
|---|---|
position(LatLng position) | 位置 |
text(String text) | 文字内容 |
fontSize(float fontSize) | 字号 |
textColor(int textColor) / fontColor(int color) | 字体颜色 |
backgroundColor(int color) | 背景色 |
align(int align) | 对齐 |
rotation(float rotation) / rotate(float r) | 旋转 |
zIndex(float zIndex) | 层级 |
visible(boolean visible) | 可见性 |
NavigateArrow
com.sfmap.api.maps.model.NavigateArrow
导航箭头。由 MapController.addNavigateArrow(NavigateArrowOptions) 返回。
| 方法 | 说明 |
|---|---|
List<LatLng> getPoints() / void setPoints(List<LatLng> points) | 点列表 |
float getWidth() / void setWidth(float width) | 宽度 |
int getTopColor() / void setTopColor(int topColor) | 顶部颜色 |
int getSideColor() / void setSideColor(int sideColor) | 侧面颜色 |
float getZIndex() / void setZIndex(float zIndex) | 层级 |
boolean isVisible() / void setVisible(boolean visible) | 可见性 |
void remove() / String getId() | 移除/id |
NavigateArrowOptions
| 方法 | 说明 |
|---|---|
add(LatLng point) / add(LatLng... points) / addAll(Iterable<LatLng> points) | 添加点 |
width(float width) | 宽度 |
topColor(int color) | 顶部颜色 |
sideColor(int color) | 侧面颜色 |
zIndex(float zIndex) | 层级 |
visible(boolean visible) | 可见性 |
GroundOverlay
com.sfmap.api.maps.model.GroundOverlay
地面图层。由 MapController.addGroundOverlay(GroundOverlayOptions) 返回。
| 方法 | 说明 |
|---|---|
LatLng getPosition() / void setPosition(LatLng position) | 位置 |
void setImage(BitmapDescriptor image) | 图片 |
float getWidth() / float getHeight() / void setDimensions(float width, float height) | 尺寸(米) |
float getTransparency() / void setTransparency(float transparency) | 透明度 |
float getBearing() / void setBearing(float bearing) | 旋转方向 |
void setPositionFromBounds(LatLngBounds bounds) | 通过边界设置位置 |
float getZIndex() / void setZIndex(float zIndex) | 层级 |
boolean isVisible() / void setVisible(boolean visible) | 可见性 |
void remove() / String getId() | 移除/id |
GroundOverlayOptions
| 方法 | 说明 |
|---|---|
image(BitmapDescriptor image) | 图片 |
position(LatLng location, float width, float height) | 位置+尺寸 |
positionFromBounds(LatLngBounds bounds) | 通过边界定位 |
bearing(float bearing) | 旋转方向 |
transparency(float transparency) | 透明度 |
zIndex(float zIndex) | 层级 |
visible(boolean visible) | 可见性 |
TileOverlay
com.sfmap.api.maps.model.TileOverlay
瓦片图层。由 MapController.addTileOverlay(TileOverlayOptions) 返回。
| 方法 | 说明 |
|---|---|
TileProvider getTileProvider() | 获取瓦片提供者 |
boolean isVisible() / void setVisible(boolean visible) | 可见性 |
float getZIndex() / void setZIndex(float z) | 层级 |
void clearTileCache() | 清除瓦片缓存 |
void remove() / String getId() | 移除/id |
TileOverlayOptions
| 方法 | 说明 |
|---|---|
tileProvider(TileProvider tileProvider) | 瓦片提供者 |
visible(boolean visible) | 可见性 |
zIndex(float zIndex) | 层级 |
fadeIn(boolean fadeIn) | 是否淡入 |
memCacheSize(int memCacheSize) | 内存缓存大小(字节),默认 6MB |
diskCacheSize(int diskCacheSize) | 磁盘缓存大小(字节),默认 16MB,0/负值关闭 |
diskCacheDir(String path) | 磁盘缓存目录绝对路径 |
memoryCacheEnabled(boolean enabled) | 内存缓存开关(默认 true) |
diskCacheEnabled(boolean enabled) | 磁盘缓存开关(默认 true) |
Tile
com.sfmap.api.maps.model.Tile(实现 Parcelable)
| 字段 | 类型 | 说明 |
|---|---|---|
width | int | 像素宽度 |
height | int | 像素高度 |
data | byte[] | 图片数据字节数组 |
构造:Tile(int width, int height, byte[] data)
TileProvider
com.sfmap.api.maps.model.TileProvider(接口)
| 方法 | 说明 |
|---|---|
Tile getTile(int x, int y, int zoom) | 获取指定坐标和缩放级别的瓦片 |
int getTileWidth() | 瓦片像素宽 |
int getTileHeight() | 瓦片像素高 |
常量:Tile NO_TILE = new Tile(-1, -1, null) // 空瓦片标记
UrlTileProvider
com.sfmap.api.maps.model.UrlTileProvider(abstract,实现 TileProvider)
只需提供一个 URL,要求所有图像尺寸相同。
| 方法 | 说明 |
|---|---|
UrlTileProvider(int width, int height) | 构造 |
abstract URL getTileUrl(int x, int y, int zoom) | 返回指定 tile 坐标对应图片 URL |
final Tile getTile(int x, int y, int zoom) | 内部通过 URL 下载 |
int getTileWidth() / int getTileHeight() | 瓦片宽/高 |
Map<String, String> getUrlRequestProperties() | 附加 HTTP 请求头 |
Heatmap
com.sfmap.api.maps.model.Heatmap
热力图。由 MapController.addHeatmapOverlay(HeatmapOptions) 返回。
| 方法 | 说明 |
|---|---|
Collection<WeightedLatLng> getData() / void setData(Collection<WeightedLatLng> data) | 数据 |
int getRadius() / void setRadius(int radius) | 半径(像素) |
Gradient getGradient() / void setGradient(Gradient gradient) | 渐变色 |
double getOpacity() / void setOpacity(double opacity) | 透明度 |
int getType() / void setType(int type) | 形态(TYPE_POINT/TYPE_GRID/TYPE_HEXAGON) |
int getCellSize() / void setCellSize(int cellSize) | cell 边长(米) |
float getZIndex() / void setZIndex(float zIndex) | 层级 |
boolean isVisible() / void setVisible(boolean visible) | 可见性 |
void remove() / String getId() | 移除/id |
HeatmapOptions
| 方法 | 说明 |
|---|---|
data(Collection<WeightedLatLng> data) | 带权值点集合 |
radius(int radius) | 点半径(像素),10~50,默认 12 |
gradient(Gradient gradient) | 渐变色 |
opacity(double opacity) | 透明度(0~1),默认 0.6 |
transparency(double transparency) | opacity 别名 |
type(int type) | 形态,默认 TYPE_POINT |
cellSize(int cellSizeMeters) | cell 边长(米),仅 GRID/HEXAGON,>=50,默认 500 |
zIndex(float zIndex) | 层级 |
visible(boolean visible) | 可见性 |
HeatmapTileProvider
com.sfmap.api.maps.model.HeatmapTileProvider
热力图 TileProvider,通过 Builder 构造,map.addTileOverlay(new TileOverlayOptions().tileProvider(provider)) 添加。
常量:TYPE_POINT=0、TYPE_GRID=1、TYPE_HEXAGON=2、DEFAULT_RADIUS=12、DEFAULT_OPACITY=0.6、DEFAULT_CELL_SIZE=500
Builder 方法:
| 方法 | 说明 |
|---|---|
data(Collection<LatLng> collection) | 无权值数据(intensity 默认 1.0) |
weightedData(Collection<WeightedLatLng> collection) | 带权值数据 |
radius(int radius) | 半径(10~50),默认 12 |
gradient(Gradient gradient) | 渐变 |
transparency(double transparency) | 透明度(0~1),默认 0.6 |
type(int type) | 形态 |
cellSize(int cellSizeMeters) | cell 边长(米),>=50,默认 500 |
HeatmapTileProvider build() | 构造,需先设置数据 |
Gradient
com.sfmap.api.maps.model.Gradient
| 方法 | 说明 |
|---|---|
Gradient(int[] colors, float[] startPoints) | 构造,startPoints 须递增,长度与 colors 一致 |
int[] getColors() | 渐变色数组 |
float[] getStartPoints() | 起始点数组 |
int getColorMapSize() | 色图大小(默认 1000) |
boolean isValid() | 是否构造有效 |
WeightedLatLng
com.sfmap.api.maps.model.WeightedLatLng
| 字段 | 类型 | 说明 |
|---|---|---|
latLng | LatLng | 坐标 |
intensity | double | 权值 |
构造:WeightedLatLng(LatLng latLng, double intensity) / WeightedLatLng(LatLng latLng)(默认权值 DEFAULT_INTENSITY=1.0)
BitmapDescriptorFactory
com.sfmap.api.maps.model.BitmapDescriptorFactory
创建 BitmapDescriptor 的工厂。全部方法为 static。
颜色常量
MARKER_COLOR_RED=0、_ORANGE=1、_YELLOW=2、_GREEN=3、_CYAN=4、_AZURE=5、_BLUE=6、_VIOLET=7、_MAGENTA=8、_ROSE=9
方法
| 方法 | 说明 |
|---|---|
BitmapDescriptor fromResource(int resourceId) | 根据资源 ID 创建 |
BitmapDescriptor fromPath(String absolutePath) | 根据绝对路径创建 |
BitmapDescriptor fromFile(String fileName) | 根据手机存储文件名创建 |
BitmapDescriptor fromAsset(String assetName) | 根据 asset 文件名创建(@Deprecated) |
BitmapDescriptor defaultMarker() | 默认红色水滴形 marker |
BitmapDescriptor defaultMarker(int hue) | 指定颜色(MARKER_COLOR_*)的 marker |
BitmapDescriptor fromBitmap(Bitmap image) | 根据 Bitmap 创建 |
BitmapDescriptor fromView(View view) | 根据 View 创建(将 View 绘制为 Bitmap) |
BitmapDescriptor
| 方法 | 说明 |
|---|---|
Bitmap getBitmap() | 获取 Bitmap 对象 |
int getWidth() / int getHeight() | 宽/高 |
BitmapDescriptor clone() | 克隆 |
void recycle() | 销毁(兼容老 SDK,不主动 recycle) |
