google maps marker array?

随声附和 提交于 2019-12-06 22:05:30

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

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);
}

final output

hope this will help! Happy coding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!