在Android的另一个图标之上的图标

发布于 2025-02-12 11:45:25 字数 1087 浏览 3 评论 0原文

我正在编码一个类似于Java的Android应用程序(使用Java),我使用Google Maps SKD的两种标记:一个用于我当前的位置,另一个指示我的位置。

我为这些标记设置了两个不同的图标,如何将其中一个给予优先级? 我希望MU当前位置图标标记在所有其他图标标记上显示,我该怎么做?

谢谢您的时间:)

编辑:这是我使用的一些代码,用于我当前的位置标记

        Drawable arrowDrawable = getResources().getDrawable(R.drawable.current_position_icon);
        BitmapDescriptor arrowIcon = getMarkerIconFromDrawable(arrowDrawable);

        Marker currentPositionMarker = gMap.addMarker(new MarkerOptions()
                .position(new LatLng(location.getLatitude(), location.getLongitude()))
                .draggable(false)
                .rotation(location.getBearing())
                .icon(arrowIcon)
                .flat(true));

,这是我用来设置其他标记的代码

    Marker marker = gMap.addMarker(new MarkerOptions()
            .position(new LatLng(event.getLatitude(), event.getLongitude()))
            .title("Acc. value -> " + Double.toString(event.getAccelerometerValue()))
            .icon(potholeIcon)
            .draggable(false));

,这是我使用标记的唯一一次,我不使用它我的XML或其他Java代码。

I'm coding an android app (using java) maps-like and I use two kind of markers from Google Maps SKD: one for my current position, the other one indicates me places of intereset.

I set two different icons for these markers, how can I give to one of them the priority?
I want mu current position icon marker to be shown over all other icon markers, how can I do that?

Thank you for time :)

EDIT: here's some code I'm using for my current position marker

        Drawable arrowDrawable = getResources().getDrawable(R.drawable.current_position_icon);
        BitmapDescriptor arrowIcon = getMarkerIconFromDrawable(arrowDrawable);

        Marker currentPositionMarker = gMap.addMarker(new MarkerOptions()
                .position(new LatLng(location.getLatitude(), location.getLongitude()))
                .draggable(false)
                .rotation(location.getBearing())
                .icon(arrowIcon)
                .flat(true));

And here's some code I'm using to set my other markers

    Marker marker = gMap.addMarker(new MarkerOptions()
            .position(new LatLng(event.getLatitude(), event.getLongitude()))
            .title("Acc. value -> " + Double.toString(event.getAccelerometerValue()))
            .icon(potholeIcon)
            .draggable(false));

It's the only time where I use my markers, I don't use it im my XML or in other Java code.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寄意 2025-02-19 11:45:25

渲染其他所有图标后,渲染“当前位置图标”。

如果是XML,请最后添加。

如果是在Java中,则只需声明并将其添加到最后一个布局。

如果您无法提供代码,则无法提供代码...

编辑:

确定我的想法,我将提供一些代码。

XML:

    <Layout...>
        <Other_Icon.../>
        <Other_Icon.../>
        <Other_Icon.../>
        <Your_Current_Position.../>
    </Layout...>

Java:

    Layout layout=new Layout(...);
    //A lot of other icons...
    layout.addView(icon1);
    layout.addView(icon2);
    layout.addView(icon3);
    //Your position icon...
    layout.addView(your_current_position_icon);

或者,如果您使用的是拖放。

只需最后放置图标即可。

(但是,如果您为确保确定编写编码,那就更好了。)

Render your "current position icon" after you rendered every other icon.

If it's XML then just add it last.

If it's in Java then just declare and add it to the layout last.

Can't provide code if you can't provide code though...

Edit:

Made out my mind, I'll provide some code.

XML:

    <Layout...>
        <Other_Icon.../>
        <Other_Icon.../>
        <Other_Icon.../>
        <Your_Current_Position.../>
    </Layout...>

Or

Java:

    Layout layout=new Layout(...);
    //A lot of other icons...
    layout.addView(icon1);
    layout.addView(icon2);
    layout.addView(icon3);
    //Your position icon...
    layout.addView(your_current_position_icon);

Or, if you are using drag-and-drop.

Just drop the icon last.

(But it would be better if you code it instead just to make sure.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文