Google Maps coordinates to perspective map image coordinates

十年热恋 提交于 2019-12-13 08:58:40

问题


I'm creating an android app that uses a image as a map.

I have a image in perspective and need to put some pins and show the user where he is.

How can I convert the google maps coordinates to the position in the image?

Thank you


回答1:


there is no code to share here since it it dependent on how you show the image (I assume you are not using GoogleMap object and ground overlay...

You have to create your specific function for reprojecting the image coordinates (that you can try to normalize between 0 and 1) and the world coordinates (which depends on where in the world is that place).

If you are using instead GoogleMap object, you can place that image over google maps and then use the normal coordinates; here the page: https://developers.google.com/maps/documentation/android/groundoverlay

you can add it by:

LatLng NEWARK = new LatLng(40.714086, -74.228697);
GroundOverlayOptions newarkMap = new GroundOverlayOptions()
        .image(BitmapDescriptorFactory.fromResource(R.drawable.newark_nj_1922))
        .position(NEWARK, 8600f, 6500f);
map.addGroundOverlay(newarkMap);

Obviously you have to find your position and check the documentation on which method use, because you can use the above one or a few others:

position(LatLng location, float width, float height)
position(LatLng location, float width)
positionFromBounds(LatLngBounds bounds)

PS: If you are not using GoogleMap objects this question is not "google-maps" related but GIS-geopositioning related (I would suggest https://gis.stackexchange.com/ in this case).



来源:https://stackoverflow.com/questions/31255433/google-maps-coordinates-to-perspective-map-image-coordinates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!