动态更改transformCenter [英] Change the transformCenter dynamically
问题描述
我正在使用Android SDK Premium 3.9.我的目标是:
I'm using HERE Android SDK Premium 3.9. My objective is this:
- 首先在屏幕上的某个
PointF
处显示用户的当前位置 - 基于某些条件,我想在屏幕上添加一个目标标记".目的地标记位于与当前位置不同的位置.该标记不能位于中心-而是必须由某个
PointF
偏移
- Start off by showing the current location of the user at a certain
PointF
on the screen - 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.
推荐答案
- 确保使用有效的
PointF
呼叫Map.setTransformCenter(PointF)
. X和Y应该在[x from 0 to map.getWidth(), y from 0 to map.getHeight()]
范围内. - 方法
Map.setTransformCenter
只是一个设置器,您需要进行另一个方法调用,例如Map.setCenter()
或Map.zoomTo()
.看看它是如何工作的.
- Make sure you call
Map.setTransformCenter(PointF)
with validPointF
. X and Y should be within[x from 0 to map.getWidth(), y from 0 to map.getHeight()]
range. - Method
Map.setTransformCenter
is only a setter, you need to make another method call likeMap.setCenter()
orMap.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屋!