如何创建自定义信息窗口?

时间:2015-08-25 15:43:56

标签: android

我正在尝试在Google地图标记上方创建自定义信息窗口(不同大小,颜色和地址)。这是我的代码:

public void setUpMap() {
        if (mMap == null) {

        mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
        mMap.setMyLocationEnabled(true);

        if (mMap != null) {

            mMap.setOnMyLocationChangeListener(new GoogleMap.OnMyLocationChangeListener() {

                @Override
                public void onMyLocationChange(Location arg0) {

                    LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

                    Criteria criteria = new Criteria();
                    String provider = locationManager.getBestProvider(criteria, true);
                    Location myLocation = locationManager.getLastKnownLocation(provider);

                    mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);

                    double latitude = myLocation.getLatitude();
                    double longitude = myLocation.getLongitude();
                    LatLng latLng = new LatLng(latitude, longitude);

                    mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
                    mMap.animateCamera(CameraUpdateFactory.zoomTo(14));

                    Marker Marker = mMap.addMarker(new MarkerOptions()
                            .icon(BitmapDescriptorFactory.fromResource(R.drawable.map_marker))
                            .anchor(0.0f, 1.0f)
                            .position(new LatLng(arg0.getLatitude(), arg0.getLongitude()))
                            .title("Locatie:"  ));
                    mMap.setInfoWindowAdapter();


                }

            });

        }
    }

}

0 个答案:

没有答案