这里在Android示例中映射自定义InfoWindow

时间:2017-05-26 06:17:38

标签: android here-api android-maps

在这里映射如何添加标记点击并在Android中显示自定义窗口信息适配器,如谷歌地图

感谢enter image description here

这是代码,在此代码中,我们在一个特定的Lat Long上添加标记。我的问题是我想添加InfoBubble(单击标记时自定义窗口)

    private void initialize() {
    setContentView(R.layout.activity_main);

    // Search for the map fragment to finish setup by calling init().
    mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.mapfragment);
    mapFragment.init(new OnEngineInitListener() {
        @Override
        public void onEngineInitializationCompleted(OnEngineInitListener.Error error) {
            if (error == OnEngineInitListener.Error.NONE) {
                // retrieve a reference of the map from the map fragment
                map = mapFragment.getMap();

                com.here.android.mpa.common.Image iconLocationMarker = new com.here.android.mpa.common.Image();
                try {
                    iconLocationMarker.setImageResource(R.drawable.ic_placeholder_black_shape_for_localization_on_maps_1);


                } catch (IOException e) {
                    //finish();
                }
                map.setCenter(new GeoCoordinate(28.6209139, 77.3726377),
                        Map.Animation.NONE);
                // Set the map center to the Vancouver region (no animation)
                map.setCenter(new GeoCoordinate(28.6246819,77.3778036, 0.0),
                        Map.Animation.NONE);
                // Set the zoom level to the average between min and max
               // mapFragment.getMap().getL
                GeoCoordinate coordinate = new GeoCoordinate(28.6209139, 77.3726377);
                map.setZoomLevel((map.getMaxZoomLevel() + map.getMinZoomLevel()) / 2);
                MapMarker pickupMarker = new MapMarker(coordinate, iconLocationMarker);
                pickupMarker.setTitle("working ");
                String snippet = pickupMarker.getDescription();

                map.addMapObject(pickupMarker);
            } else {
                Log.e(LOG_TAG, "Cannot initialize MapFragment (" + error + ")");
            }
        }
    });
}

0 个答案:

没有答案