Android的:如何:使用移动当前位置指针显示的地图(静止图像文件)当前位置、指针、图像文件、地图

2023-09-12 10:14:18 作者:是非之地

我想创建一个原型,可以引导人,以他的目的地。

I am trying to create a prototype that could guide a person to his destination place.

将是一个广泛的建筑用几个楼层。 我可以获得/检索地图(静止图像)。 例如。当前:1F目的地:5F;这样我就可以拿到第一,第二...... 5楼的静止图像(5图像文件)。

方案:

在启动应用程序 输入当前位置和放大器(或可自动使用当前的位置设置);目的地 点击搜索路线按钮,搜索地图使用(静止图像)及标记当前的位置和放大器;目的地 在移动时更新当前的位置/去目的地

问题:

我只需要为显示1的图像文件(每个楼层)的时间,然后使用滚动条移动到其他楼层。不过......不知道如何来显示它。 我可以通过WiFi,但当前位置的坐标不知道如何把它变成静态图像标记当前位置 I just need to display 1 image file (each floor) at a time then move to other floor by using scroll bar. But.. don't know how to display it. I can get the current location coordinate via WiFi but don't know how to put it into still image to mark the current location.

有关肯定有已经可以看一个样的应用程序。 你能共享的概念/想法,或者你将包括code片段。很大的帮助,我的论文。

For sure there is already look a like sample application available. Could you share the concepts/ideas or would you include the code snippets. Big Help with my thesis.

这是朝着正确的方向任何指导的AP preciated。

Any guidance on the right direction is appreciated.

推荐答案

您有几个可能性,创建你自己的MapView状物体,以提供滚动OT覆盖地图上的谷歌API。的MapView的API用法示例可通过位置开发指南。

You have a couple possibilities, create your own MapView like object to provide scrolling ot overlay your map on the Google Api. Example usage of the MapView Api is available through the Location dev guide.

要通过自己的视图做到这一点会更容易,如果你懂得基本的图形编程和转换的缩放和平移。 (如果你擅长数学这将是没有问题的学习)。请使用ImageView的与机器人:scaleType =矩阵覆盖MotionEvent处理程序来获得触摸,然后加工成一个tranlation和变焦矩阵

To do this via your own View will be easier if you understand basic graphics programming and transformations for zoom and pan. (If you're good at math it will be no trouble to learn). Use an ImageView with android:scaleType="matrix" override the MotionEvent handler to get the touches then process them into a tranlation and zoom matrix.

要在指标的映像关联使两个像素成coorespond到现实生活中的纬度/长锚点。通常它的(0,0)和一个矩形图像的(宽度,高度)。使您的生活更轻松,并确保图像缩放。然后使用第二ImageView的(为指标)绘制在上面,将其移动到正确的位置在屏幕上,并确保该视图中的背景是透明的,以及你的指标的背景或你就会有一个矩形块光环。

To associate the indicator to the image make two pixels into anchor points that coorespond to a real life lat/long. Usually its (0,0) and (width,height) of a rectangular image. Make your life easier and make sure the images are to scale. Then using a second ImageView (for the indicator) draw it on top and move it to the correct place on the screen and make sure the background in this View is transparent as well as the background of your indicator or you'll have a rectangular block "halo".

请务必检查由LocationManager给每个位置的精度。

Be sure to check the accuracies of each location given by the LocationManager.

其他内容

onCurrentPosition(Location current){
    double hypotenuse = upperLeft.distanceTo(current);
    double bearing = upperLeft.bearingTo(current);
    double currentDistanceX = Math.cos(bearing) * hypotenuse;
    //                     "percentage to mark the position"
    double currentPixelX = (currentDistanceX / upperLeft.distanceTo(lowerRight) * Math.cos(upperLeft.bearingTo(lowerRight))) * mapWidth;

    moveIndicatorX(currentPixelX);
}