将lat lng添加到clusterkraf

时间:2013-10-30 07:38:45

标签: android google-maps-android-api-2 markerclusterer

我已经在我的地图v2项目中导入了clusterkraf。现在我该如何添加latlng点?

我添加了此代码,我不知道如何添加10个lat lng点 我从来没有真正找到除下面代码之外的任何方法。我非常感谢任何帮助。

先谢谢。

  public class YourMapPointModel {
        public LatLng latLng;
        public YourMapPointModel(LatLng latLng) {
            this.latLng = latLng;
        }
        // encapsulation omitted for brevity
    }

    public class YourActivity extends FragmentActivity {
        YourMapPointModel[] yourMapPointModels = new YourMapPointModel[] { new YourMapPointModel(new LatLng(0d, 1d) /* etc */ ) };
        ArrayList<InputPoint> inputPoints;

        private void buildInputPoints() {
            this.inputPoints = new ArrayList<InputPoint>(yourMapPointModels.length);
            for (YourMapPointModel model : this.yourMapPointModels) {
                this.inputPoints.add(new InputPoint(model.latLng, model));
            }
        }



        Clusterkraf clusterkraf;

        private void initClusterkraf() {
            if (googleMap != null && this.inputPoints != null && this.inputPoints.size() > 0) {
                com.twotoasters.clusterkraf.Options options = new com.twotoasters.clusterkraf.Options();
                // customize the options before you construct a Clusterkraf instance
                this.clusterkraf = new Clusterkraf(googleMap, options, this.inputPoints);
            }
        }

    }

2 个答案:

答案 0 :(得分:1)

您可以使用以下代码:

        Position_mark = new LatLng(35.7008, 51.437);
        Marker hamburg = map.addMarker(new MarkerOptions().position(
                Position_mark).title("Hamburg"));

        Position_Now = Position_mark;
        map.moveCamera(CameraUpdateFactory.newLatLngZoom(Position_mark,
                15));

        map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);

并将命令放入for(;;).....中,增加10分

答案 1 :(得分:0)

在Google Maps V2中测试Google方向库的路由点

https://github.com/jd-alexander/Google-Directions-Android