安卓智能地图开发与实施十九:符号与渲染器 - ArcGIS Runtime SDK for Android(Version 100.1.0)

网友投稿 888 2022-10-27

安卓智能地图开发与实施十九:符号与渲染器 - ArcGIS Runtime SDK for Android(Version 100.1.0)

安卓智能地图开发与实施十九:符号与渲染器 - ArcGIS Runtime SDK for Android(Version 100.1.0)

符号与渲染器

符号与渲染器(Symbols and Renderers),通过色彩值、大小、形状、边线、透明度来表达空间要素的具体含义。如果仅仅有位置,而没有位置上的属性信息,位置也会失去意义,符号与渲染器是呈现位置上属性信息的最直接表达方式。对于Graphic(GraphicsOverlay),可以直接赋值符号或者设置渲染器,而对于Feature(FeatureLayer)只能通过渲染器进行设置。

点符号(MarkerSymbol)

OffsetX OffsetY Angle 边线: SimpleLineSymbol SimpleMarkerSymbol 样式:

CIRCLECROSSDIAMONDSQUARETRIANGLEX

颜色(带透明度) 大小 PictureMarkerSymbol 图片:BitmapDrawable(手机存储资源、工程内部Drawable)、URL(网络图片)

PictureMarkerSymbol -手机存储资源

BitmapDrawable pinBlankOrangeDrawable = (BitmapDrawable) Drawable.createFromPath(mPinBlankOrangeFilePath);final PictureMarkerSymbol pinBlankOrangeSymbol = new PictureMarkerSymbol(pinBlankOrangeDrawable); pinBlankOrangeSymbol.setHeight(20);pinBlankOrangeSymbol.setWidth(20);pinBlankOrangeSymbol.setOffsetY(10); //高度的一半pinBlankOrangeSymbol.loadAsync();

PictureMarkerSymbol -工程内部Drawable

BitmapDrawable pinStarBlueDrawable = (BitmapDrawable) ContextCompat.getDrawable(this, R.drawable.pin_star_blue);final PictureMarkerSymbol pinStarBlueSymbol = new PictureMarkerSymbol(pinStarBlueDrawable);pinStarBlueSymbol.setHeight(40);pinStarBlueSymbol.setWidth(40);pinStarBlueSymbol.setOffsetY(11); pinStarBlueSymbol.loadAsync();

PictureMarkerSymbol - 使用网络图片

final PictureMarkerSymbol campsiteSymbol = new PictureMarkerSymbol(" AntiAlias SimpleLineSymbol 样式:

DASHDASH_DOTDASH_DOT_DOTDOTSOLIDNULL

颜色(带透明度)

SimpleLineSymbol whiteOutline =new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.rgb(255, 255, 255), 1);

面符号(FillSymbol)

边线: SimpleLineSymbol SimpleFillSymbol 样式:

BACKWARD_DIAGONALFORWARD_DIAGONALDIAGONAL_CROSSHORIZONTALVERTICALCROSSSOLIDNULL

颜色(带透明度) PictureFillSymbol 图片:URL(网络图片) 通过静态方法 (public static ListenableFuture createAsync(final BitmapDrawable drawable)) BitmapDrawable(手机存储资源、工程内部Drawable)

SimpleFillSymbol mSFS = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, Color.RED, mPolylinePlacedSymbol);

符号使用

SimpleMarkerSymbol symbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, Color.RED, 12); Point graphicPoint = new Point(-226773, 6550477, SpatialReferences.getWebMercator());Graphic graphic = new Graphic(graphicPoint, symbol);graphicsOverlay.getGraphics().add(graphic)Graphic graphic = new Graphic(graphicPoint);graphic.setSymbol(symbol);graphicsOverlay.getGraphics().add(graphic)

渲染器 - 单一符号渲染(SimpleRenderer)

Point pointGeometry = new Point(40e5, 40e5, SpatialReferences.getWebMercator());SimpleMarkerSymbol pointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.DIAMOND, Color.RED, 10);Graphic pointGraphic = new Graphic(pointGeometry);GraphicsOverlay pointGraphicOverlay = new GraphicsOverlay();SimpleRenderer pointRenderer = new SimpleRenderer(pointSymbol);pointGraphicOverlay.setRenderer(pointRenderer);pointGraphicOverlay.getGraphics().add(pointGraphic);mMapView.getGraphicsOverlays().add(pointGraphicOverlay);

渲染器 - 唯一值渲染(UniqueValueRenderer)

UniqueValueRenderer uniqueValueRenderer = new UniqueValueRenderer();uniqueValueRenderer.getFieldNames().add("STATE_ABBR"); SimpleFillSymbol defaultFillSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.NULL, Color.BLACK, new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.GRAY, 2));SimpleFillSymbol californiaFillSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, Color.RED, new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.RED, 2));SimpleFillSymbol arizonaFillSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, Color.GREEN, new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.GREEN, 2));SimpleFillSymbol nevadaFillSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID,Color.BLUE, new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.BLUE, 2));uniqueValueRenderer.setDefaultSymbol(defaultFillSymbol);uniqueValueRenderer.setDefaultLabel("Other");List californiaValue = new ArrayList<>();californiaValue.add("CA");uniqueValueRenderer.getUniqueValues().add(new UniqueValueRenderer.UniqueValue("California", "State of California", californiaFillSymbol, californiaValue));List arizonaValue = new ArrayList<>();arizonaValue.add("AZ");uniqueValueRenderer.getUniqueValues().add(new UniqueValueRenderer.UniqueValue("Arizona", "State of Arizona", arizonaFillSymbol, arizonaValue));List nevadaValue = new ArrayList<>();nevadaValue.add("NV");uniqueValueRenderer.getUniqueValues().add(new UniqueValueRenderer.UniqueValue("Nevada", "State of Nevada", nevadaFillSymbol, nevadaValue));featureLayer.setRenderer(uniqueValueRenderer);

结尾

源程序请自行-: 链接:​​​密码:vmin

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:PySpark算子处理空间数据全解析(14)外篇:经纬度数据利用Uber H3进行聚合统计...
下一篇:白话空间统计二十三回归分析番外:残差可视化
相关文章

 发表评论

暂时没有评论,来抢沙发吧~