简体   繁体   English

如何在 map 视图中画圆?

[英]how to draw circle in map view?

hi i wanna draw a circle in map view ( my map is Neshan ) but i can't understand the documantion of https://platform.neshan.org/android-sdk/reference/1.0.0/doc/org/neshan/mapsdk/model/Circle.html if anyone draw circle with carto and linestyle can share this piece of code?嗨,我想在 map 视图中画一个圆圈(我的 map 是 Neshan),但我无法理解https://platform.neshan.org/android-sdk/reference/1.0.0/doc/org/neshan/的文档mapsdk/model/Circle.html如果有人用carto和linestyle画圆可以分享这段代码吗?

public void Draw_Circle() { public void Draw_Circle() {

    Color color=new Color(0x000000);
    Circle circleOptions = new Circle(lastSectedLoc,radius,color,getLineStyle());


   map.addCircle(circleOptions);
}
private LineStyle getLineStyle(){
    LineStyleBuilder lineStCr = new LineStyleBuilder();
    lineStCr.setColor(new Color((short) 2, (short) 119, (short) 189, (short)190));
    lineStCr.setWidth(12f);
    lineStCr.setStretchFactor(0f);
    return lineStCr.buildStyle();
}

this is my code i tried to draw circle and it crash这是我的代码,我试图画圆但它崩溃了

for drawing circle in android map view you can try this:要在 android map 视图中绘制圆,您可以试试这个:

private void drawCircle(LatLng point){

// Instantiating CircleOptions to draw a circle around the marker
CircleOptions circleOptions = new CircleOptions();
// Specifying the center of the circle
circleOptions.center(point);
// Radius of the circle
circleOptions.radius(100);
// Border color of the circle
circleOptions.strokeColor(Color.BLACK);
// Fill color of the circle
circleOptions.fillColor(0x30ff0000);
// Border width of the circle
circleOptions.strokeWidth(2);
// Adding the circle to the GoogleMap
mMap.addCircle(circleOptions);

}

for ref please refer: circle in maps参考请参考: 地图中的圆圈

add this line in your app build.gradle在您的应用中添加此行 build.gradle

implementation group: 'com.vividsolutions', name: 'jts', version: '1.13'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM