谷歌地图标记数组? [英] google maps marker array?

查看:112
本文介绍了谷歌地图标记数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

男生和女生:))

这段代码创建了一个空指针异常

this piece of code creates a null pointer exception

我想在MO中添加几个标记

I would like to put a couple of markers in MO

LAT = Double.parseDouble(PartA); LNG = Double.parseDouble(PartB);

LAT = Double.parseDouble(PartA); LNG = Double.parseDouble(PartB);

                        LatLng Standort = new LatLng(LAT, LNG);
                          MO[y] = mMap.addMarker(new MarkerOptions()
                                                    .position(Standort)
                                                    .icon(BitmapDescriptorFactory.fromResource(R.drawable.kreis)));
                        builder.include(MO[y].getPosition());

期望的数组类型-找到com.google.android.gms.maps.model.maker

Array type expected - found com.google.android.gms.maps.model.maker

定义私有静态标记MOrt = null;

Definition private static Marker MOrt = null;

推荐答案

我不知道我的回答对您有没有帮助.

I don't know my answer help you out or not.

首先声明array,然后添加点并添加标记,只需使用添加标记功能开始循环即可.

First of all declare array , than add points and for adding marker i just start a loop with add marker function.

LatLng[] point_new = new LatLng[3];
        point_new[0] = new LatLng(24.8926596, 67.0835093);
        point_new[1] = new LatLng(48.85837,2.294481);
        point_new[2] = new LatLng(0, 0);
        for (int i = 0; i < point_new.length; i++) {
            drawMarker(point_new[i]);
        }

       //drawMarker method
        private void drawMarker(LatLng point) {
    // Creating an instance of MarkerOptions
    MarkerOptions markerOptions = new MarkerOptions();

    // Setting latitude and longitude for the marker
    markerOptions.position(point);

    // Adding marker on the Google Map
    map.addMarker(markerOptions);
}

最终输出

希望这会有所帮助! 编码愉快

hope this will help! Happy coding

这篇关于谷歌地图标记数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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