动态更改transformCenter [英] Change the transformCenter dynamically

查看:118
本文介绍了动态更改transformCenter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Android SDK Premium 3.9.我的目标是:

I'm using HERE Android SDK Premium 3.9. My objective is this:

  1. 首先在屏幕上的某个PointF处显示用户的当前位置
  2. 基于某些条件,我想在屏幕上添加一个目标标记".目的地标记位于与当前位置不同的位置.该标记不能位于中心-而是必须由某个PointF
  3. 偏移
  1. Start off by showing the current location of the user at a certain PointF on the screen
  2. Based on some conditions, I want to add a "destination marker" on the screen. The destination marker is at a different location than the current location. This marker must not be at the center - rather it must be offset by a certain PointF

我无法实现这一目标.我可以将setTransformCenter一次用于初始当前位置",并且它会生效.但是,如果我再次调用它,它似乎没有生效.我在第2步中添加的标记永远不会位于正确的位置.

I haven't been able to achieve this. I can use setTransformCenter once for the initial "current location" and it takes effect. However if I call it again, it doesn't seem to take effect. My marker that I added in step 2 is just never at the correct position.

这是一些伪代码:

hereMap.setTransformCenter(positionIndicatorPoint);

GeoCoordinate markerCoordinate = getMarkerCoordinates();
MapMarker marker = new MapMarker();
marker.setCoordinate(markerCoordinate);


hereMap.setTransformCenter(mapMarkerPoint);
hereMap.addMapObject(marker);
hereMap.setCenter(marker.getCoordinate(), Map.Animation.NONE);

我在做什么错了?

显示标记时,当前位置指示器不必在屏幕上.

It is not necessary for the current position indicator to be "on-screen" when the marker is displayed.

推荐答案

  1. 确保使用有效的PointF呼叫Map.setTransformCenter(PointF). X和Y应该在[x from 0 to map.getWidth(), y from 0 to map.getHeight()]范围内.
  2. 方法Map.setTransformCenter只是一个设置器,您需要进行另一个方法调用,例如Map.setCenter()Map.zoomTo().看看它是如何工作的.
  1. Make sure you call Map.setTransformCenter(PointF) with valid PointF. X and Y should be within [x from 0 to map.getWidth(), y from 0 to map.getHeight()] range.
  2. Method Map.setTransformCenter is only a setter, you need to make another method call like Map.setCenter() or Map.zoomTo(). to see how it works.

在第二部分的伪代码中,使用hereMap.setCenter(marker.getCoordinate(), Map.Animation.NONE);,请确保您实际导航到新的地理坐标,而不是旧的地理坐标.但是实际上,即使您重新导航到旧的地理坐标,它也应该导航到新的地图中心.

In your pseudocode in the second part you use hereMap.setCenter(marker.getCoordinate(), Map.Animation.NONE);, make sure you actually navigate to the new geo coordinate, not to the old one. But actually it should navigate to the new map center even if you re-navigate to the old geo coordinate.

我制作了要点,以说明如何使用Map.setTransformCenter(PointF).

I made small gist to show how Map.setTransformCenter(PointF) can be used.

这篇关于动态更改transformCenter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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