2
A
回答
3
這裏是非常大致有:
1)初始化IndoorAtlas例如:
IndoorAtlas ia = IndoorAtlasFactory.createIndoorAtlas(context, listener, apiKey, apiSecret);
2)獲取平面圖的實例:
FutureResult<FloorPlan> result = ia.fetchFloorPlan(floorPlanId);
result.setCallback(new ResultCallback<FloorPlan>() {
@Override
public void onResult(final FloorPlan result) {
mFloorPlan = result;
loadFloorPlanImage(result);
}
// handle error conditions too
}
3)獲得的實際圖像:
void loadFloorPlanImage(FloorPlan floorPlan) {
BitmapFactory.Options options = createBitmapOptions(floorPlan);
FutureResult<Bitmap> result = ia.fetchFloorPlanImage(floorPlan, options);
result.setCallback(new ResultCallback<Bitmap>() {
@Override
public void onResult(final Bitmap result) {
// now you have floor plan bitmap, do something with it
updateImageViewInUiThread(result);
}
// handle error conditions too
}
}
4)啓動定位:在平面圖
ia.startPositioning(venueId, floorId, floorPlanId);
5)顯示的位置:
public void onServiceUpdate(ServiceState state) {
// get position on original floor plan image
int i = state.getImagePoint().getI();
int j = state.getImagePoint().getJ();
// take into account how your floor plan image has been scaled
// and draw position
PointF scaledPoint = new PointF();
Util.calculateScaledPoint((int) floorPlan.dimensions[0], (int) floorPlan.dimensions[1], i, j, mImageView, scaledPoint);
drawNewPositionInUiThread(scaledPoint.x, scaledPoint.y);
}
當然,你可以開始先定位,然後獲取圖像。你也可以在本地緩存圖片,但就像說的那樣,這大致如何。
Util.java:
public class Utils {
/**
* Calculates scaling factor for an image with original dimensions of
* {@code originalWidth x originalHeight} being displayed with {@code imageView}.
*
* The assumption with this example code is that a) layout has been already performed for
* {@code imageView} and that {@link android.widget.ImageView.ScaleType#CENTER_INSIDE} is used.
*
* @param originalWidth height of the original bitmap to be displayed using {@code imageView}
* @param originalHeight width of the original bitmap to be displayed using {@code imageView}
*/
public static float calculateScaleFactor(int originalWidth, int originalHeight,
ImageView imageView) {
if (imageView.getScaleType() != ImageView.ScaleType.CENTER_INSIDE) {
throw new IllegalArgumentException("only scale type of CENTER_INSIDE supported, was: "
+ imageView.getScaleType());
}
final int availableX = imageView.getWidth()
- (imageView.getPaddingLeft() + imageView.getPaddingRight());
final int availableY = imageView.getHeight()
- (imageView.getPaddingTop() + imageView.getPaddingBottom());
if (originalWidth > availableX || originalHeight > availableY) {
// original image would not fit without scaling
return originalWidth > availableX
? availableX/(float) originalWidth
: availableY/(float) originalHeight;
} else {
return 1f; // no scaling required
}
}
/**
* Calculates point where to draw coordinates {@code x} and {@code y} in a bitmap that's
* original dimensions were {@code originalWidth x originalHeight} and may now be scaled down
* as it's been displayed with {@code imageView}.
*
* @param originalWidth width of the original bitmap before any scaling
* @param originalHeight height of the original bitmap before any scaling
* @param x x-coordinate on original bitmap
* @param y y-coordinate on original bitmap
* @param imageView view that will be used to display bitmap
* @param point point where result value is to be stored
* @see #calculateScaleFactor(int, int, ImageView)
*/
public static void calculateScaledPoint(int originalWidth, int originalHeight,
int x, int y,
ImageView imageView,
PointF point) {
final float scale = calculateScaleFactor(originalWidth, originalHeight, imageView);
final float scaledWidth = originalWidth * scale;
final float scaledHeight = originalHeight * scale;
// when image inside view is smaller than the view itself and image is centered (assumption)
// there will be some empty space around the image (here offset)
final float offsetX = Math.max(0, (imageView.getWidth() - scaledWidth)/2);
final float offsetY = Math.max(0, (imageView.getHeight() - scaledHeight)/2);
point.x = offsetX + (x * scale);
point.y = offsetY + (y * scale);
}
}
相關問題
- 1. 使用IndoorAtlas獲取並顯示FloorPlan圖像
- 2. 如何在Google Maps iOS上顯示IndoorAtlas的FloorPlan - 目標c
- 3. 獲得在surfaceview上的點擊位置並顯示對話框
- 4. onLocationChanged不被稱爲IndoorAtlas位置管理
- 5. IndoorAtlas上的定位錯誤
- 6. 使用IndoorAtlas將位圖顯示到UI線程中
- 7. 從xml獲得的谷歌地圖位置顯示標記
- 8. 如何獲得CheckBoxList的值,並顯示
- 9. 獲得位置A的位置,並計算到B位置的距離
- 10. 如何獲取div的位置並突出顯示它
- 11. 獲取DataGridView行的顯示位置
- 12. 顯示位置
- 13. 獲得位置 - onMarkerDragEnd
- 14. 在iPhone中查找並顯示位置?
- 15. 如何獲取地理位置並在地圖上顯示
- 16. 從Firebase獲取位置並在地圖上顯示它
- 17. 試圖獲取GPS位置並在TextView中顯示
- 18. 使用延遲獲取位置並顯示地圖
- 19. CLLocation,獲得新的位置
- 20. 獲得25%位置的點?
- 21. 在任意位置顯示/隱藏並單擊任意位置
- 22. 顯示位置7
- 23. 確定是否當前位置是內部或與IndoorAtlas
- 24. 獲得當前位置定位的Android
- 25. pygame的顯示位置
- 26. 的位置沒有顯示
- 27. 的Eclipse:獲得零顯示
- 28. 獲得可用的無線網絡列表不顯示位置服務的Android
- 29. 如何通過突出顯示的位置獲得該行的文本
- 30. 獲得GPS當前位置
感謝您的答覆。我對它。但是對於1號,你如何申報聽衆? IndoorAtlasListener或另一個聽衆? –
是的,IndoorAtlasListener。基本示例可以從IndoorAtlas SDK附帶的示例應用程序中找到。 –
也許我不明白如何聲明:loadFloorPlanImage,updateImageViewInUiThread,drawNewPositionInUiThread。 你能指導我嗎? Thx –