如何更换我的Andr​​oid应用程序谷歌地图半径圆蓝色半透明的一个作为图像? [英] How do I replace my android app Google maps radius circle with a blue translucent one as in image?

查看:1579
本文介绍了如何更换我的Andr​​oid应用程序谷歌地图半径圆蓝色半透明的一个作为图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何更换我的Andr​​oid应用程序谷歌地图半径圆蓝色半透明的一个作为的形象也蓝色标记的蓝色圆圈?

我可以圆有一个特定的轮廓和填充,但它看起来并不附近的任何地方一样好,如下图中所描绘的。我怎么做?我的code迄今也低于

code:

 私人GoogleMap的GoogleMap的;

    @覆盖
    保护无效的onCreate(包savedInstanceState){
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.activity_main);

        尝试 {
            initilizeMap();

        }赶上(例外五){
            e.printStackTrace();
        }

    }
    私人无效initilizeMap(){
        如果(GoogleMap的== NULL){
            GoogleMap的=((MapFragment)getFragmentManager()。findFragmentById(
                    R.id.map))的GetMap()。


              经纬度经纬度=新的经纬度(28.982518,-81.542272);
              gooleMap.addMarker(新MarkerOptions()位置(经纬度));


              圈圈= gooleMap.addCircle(新CircleOptions()
              .center(新经纬度(28.982518,-81.542272))
              .radius(1000)
              .strokeColor(Color.RED)
              .fillColor(Color.PURPLE));

mMap.addCircle(新CircleOptions()
        .center(中心)
        .radius(半径)
        .strokeWidth(0F)
        .fillColor(0x550000FF));

        }
    }

    @覆盖
    保护无效onResume(){
        super.onResume();
        initilizeMap();
    }

}
 

Android的XML:

 < XML版本=1.0编码=UTF-8&GT?;
< RelativeLayout的的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT>

    <片段
        机器人:ID =@ + ID /图
        机器人:名称=com.google.android.gms.maps.MapFragment
        机器人:layout_width =match_parent
        机器人:layout_height =match_parent/>

< / RelativeLayout的>
 

图片:

  

要确认,我想要做的是:

显示上述的效果,深蓝色圆圈半透明的淡蓝色填充,在上面的图片

解决方案

  CircleOptions circleOptions =新CircleOptions()
        .center(经纬度)
        .radius(500)
        .strokeWidth(2)
        .strokeColor(Color.BLUE)
        .fillColor(Color.parseColor(#500084d3));
        //支持的格式有:#RRGGBB #AARRGGBB
        // #AA是α,或透明度量

    mMap.addCircle(circleOptions);
 

How do I replace my android app Google maps radius circle with a blue translucent one as in image also blue marker with blue circle?

I can make the circle have a particular outline and fill but it doesn't look anywhere near as nice as the one depicted in the image below. How do I do that? my code so far is below also.

Code:

    private GoogleMap googleMap;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        try {
            initilizeMap();

        } catch (Exception e) {
            e.printStackTrace();
        }

    }
    private void initilizeMap() {
        if (googleMap == null) {
            googleMap = ((MapFragment) getFragmentManager().findFragmentById(
                    R.id.map)).getMap();


              LatLng latLng = new LatLng(28.982518, -81.542272);
              gooleMap.addMarker(new MarkerOptions().position(latLng));


              Circle circle =  gooleMap.addCircle(new CircleOptions()
              .center(new LatLng(28.982518, -81.542272))
              .radius(1000)
              .strokeColor(Color.RED)
              .fillColor(Color.PURPLE));

mMap.addCircle(new CircleOptions()
        .center(center)
        .radius(radius)
        .strokeWidth(0f)
        .fillColor(0x550000FF));

        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        initilizeMap();
    }

}

Android xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.MapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</RelativeLayout>

Image:

To confirm, what I'm trying to do is:

Show the above effect, a dark blue circle with a translucent light blue fill as in above image

解决方案

    CircleOptions circleOptions = new CircleOptions()
        .center(latlng)
        .radius(500)
        .strokeWidth(2)
        .strokeColor(Color.BLUE)
        .fillColor(Color.parseColor("#500084d3"));
        // Supported formats are: #RRGGBB #AARRGGBB
        //   #AA is the alpha, or amount of transparency

    mMap.addCircle(circleOptions);

这篇关于如何更换我的Andr​​oid应用程序谷歌地图半径圆蓝色半透明的一个作为图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆