标签: android-mapview

如何在Android MapView中计算点周围的半径?

我有一个MapView,我正在显示一个"有用的半径"(想想坐标的准确性).使用MapView's ProjectionmeterToEquatorPixels,这当然只是赤道距离)并没有给我足够准确的距离(以像素为单位) ).如果你想在给定半径的坐标周围显示一个圆圈,你会如何计算?

gps android android-mapview

12
推荐指数
1
解决办法
1万
查看次数

禁用com.google.android.maps.MapView中的平移/缩放

如何禁用MapView的平移/缩放功能(不是缩放控件,我想要一个完全静态的地图)?

我也注意到触摸地图似乎没有触发MapView onClickListener,任何人都可以详细说明原因吗?

android android-mapview

12
推荐指数
3
解决办法
9445
查看次数

Android Geocoder getFromLocationName始终返回null

我一直在尝试对字符串进行地理编码以获取其坐标但我的程序总是崩溃,因为当我尝试使用getFromLocationName()它时返回null.我一直试图解决这个问题几个小时,但没有任何工作.这是我的代码

public class MainActivity extends Activity {

    private GoogleMap mMap;

    List<Address> addresses;
    MarkerOptions miami;
    String myLocation = "Miami,Florida";

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        if (mMap == null) {
            mMap = ((MapFragment) getFragmentManager().findFragmentById(
                    R.id.map)).getMap();
        }

        if (mMap != null) {

            Geocoder geocoder = new Geocoder(this);


            double latitude = 0;
            double longitude = 0;

            while(addresses==null){
            try {
                addresses = geocoder.getFromLocationName(myLocation, 1);

            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            }
            Address address …
Run Code Online (Sandbox Code Playgroud)

java eclipse android android-mapview google-maps-android-api-2

12
推荐指数
1
解决办法
2万
查看次数

Android - ListView中包含的MapView

目前我正在尝试在ListView中放置MapView.有人有这个成功吗?它甚至可能吗?这是我的代码:

            ListView myList = (ListView) findViewById(android.R.id.list);
        List<Map<String, Object>> groupData = new ArrayList<Map<String, Object>>();

        Map<String, Object> curGroupMap = new HashMap<String, Object>();
        groupData.add(curGroupMap);
        curGroupMap.put("ICON", R.drawable.back_icon);
        curGroupMap.put("NAME","Go Back");
        curGroupMap.put("VALUE","By clicking here");

        Iterator it = data.entrySet().iterator();
        while (it.hasNext()) 
        {
            //Get the key name and value for it
            Map.Entry pair = (Map.Entry)it.next();
            String keyName = (String) pair.getKey();
            String value = pair.getValue().toString();

            if (value != null)
            {
                //Add the parents -- aka main categories
                curGroupMap = new HashMap<String, Object>();
                groupData.add(curGroupMap);

                //Push the correct Icon
                if (keyName.equalsIgnoreCase("Phone")) …
Run Code Online (Sandbox Code Playgroud)

android listview android-mapview

11
推荐指数
3
解决办法
2万
查看次数

MapView在触摸时添加图钉

我设法让屏幕上显示地图.现在,用户将在地图上移动并按下它.按下一个点后,我需要在按下位置的屏幕上添加一个推针.如果用户决定去另一点,所选择的点压接时,第一个图钉将disapear和新的人会在新的位置绘制

我喜欢这样:

public class LocationSelectionActivity extends MapActivity 
{    
     GeoPoint p;
     List<Overlay> listOfOverlays;
     MapOverlay mapOverlay;

    private MapView mapView;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.locationselection);

        mapView = (MapView) findViewById(R.id.mapView);
        mapView.setSatellite(false);

        final MapController mc = mapView.getController();
        String coordinates[] = {"46.540606", "22.454542"};

        double lat = Double.parseDouble(coordinates[0]);
        double lng = Double.parseDouble(coordinates[1]);

         p = new GeoPoint(
            (int) (lat * 1E6), 
            (int) (lng * 1E6));

        mc.animateTo(p);
        mc.setZoom(10); 


        ZoomControls zoomControls = (ZoomControls) findViewById(R.id.zoomcontrols);
        zoomControls.setOnZoomInClickListener(new View.OnClickListener() {
                public …
Run Code Online (Sandbox Code Playgroud)

android pushpin android-mapview

11
推荐指数
1
解决办法
2万
查看次数

如何在MapView中绘制显示行车方向的箭头?

MapView在Android应用程序中使用该Google Maps组件.我可以使用GPS位置用点显示我的位置.但是我想显示一个箭头,指出行驶方向(方位).我认为我可以使用该bearing值来获得箭头的角度.

我怎样才能做到这一点?

gps android overlay bearing android-mapview

11
推荐指数
1
解决办法
1万
查看次数

使用Google Directions API地图查看绘制路线 - 解码折线

我正在尝试使用Google Directions API在我的mapview上显示路线,但我很难从JSON响应中获取数据.我可以获得"级别"和"点"字符串,但无法解决如何将它们解码到地图上的点.

任何帮助将非常感激.

android json google-maps polyline android-mapview

11
推荐指数
2
解决办法
1万
查看次数

Android Mapview:将重叠标记合并为新标记

所以我有一个带有很多标记的MapView,其中大多数都集中在英里宽的簇中.缩放时,标记重叠并且看起来只有一个.我想要实现的是在某个缩放级别用一个组标记替换重叠标记,组标记将显示标记的密度,onClick将缩放以显示内部的所有标记.我知道我可以用蛮力距离测量做到这一点,但必须有一种更有效的方法.任何人都有任何解决方案或智能算法如何实现这一目标?

algorithm android markers android-mapview

11
推荐指数
1
解决办法
7926
查看次数

带有片段的Android mapview无法添加两次?

我使用Android兼容性类与黑客在这里找到的片段中使用mapviews:https://github.com/petedoyle/android-support-v4-googlemaps

不幸的是,我发现如果mapfragment从活动中删除,然后重新读取,我得到"你只允许在MapActivity中有一个MapView"错误."

我理解错误背后的原理,并尝试在片段onPause方法中销毁mapview.不幸的是,我似乎无法完全破坏mapview,因为我仍然得到它.我的代码看起来像这样:

private RelativeLayout layout; 
private MapView mp;

public void onResume(){
    super.onResume();
    Bundle args = getArguments();
    if(mp == null)
    {
        mp = new MapView(getActivity(), this.getString(R.string.map_api_key)); 
        mp.setClickable(true);
    }

    String request = args.getString("requestId");
    layout = (RelativeLayout) getView().findViewById(R.id.mapholder);
    layout.addView(mp);
    //TextView txt = (TextView) getView().findViewById(R.id.arguments);
    //txt.setText(request);
}

public void onPause(){
    super.onPause();
    layout.removeView(mp);
    mp = null;
}
Run Code Online (Sandbox Code Playgroud)

有没有人对我在这里忽略的参考资料有什么想法?

android view android-fragments android-mapview

11
推荐指数
3
解决办法
5597
查看次数

教程 - Android Map Pin drop动画 - 正常工作

我需要我的Android应用程序的地图引脚下拉动画.做了很多研究,我没有发现任何有用的东西.所以我创造了一个小黑客.只需发布代码,以便其他人可以使用它并相应地修改它.

由于Android中的翻译动画仅适用于视图而叠加不是视图,我创建了一个小的黑客,它通过翻译动画将视图放在同一个地理位置,然后删除视图以显示叠加.这样,用户认为地图叠加层从顶部开始掉落,即使它们不是.

这是代码:

private void translateAnimation(MapView mapView,ArrayList<GeoPoint> geoPointsList,Context context) {
    Point dropPoint = new Point();
    Projection projection = mapView.getProjection(); /*
                                                      * Getting the map projections to calculate
                                                      * screen points and geopoints
                                                      */
    GeoPoint mGeoPoint = projection.fromPixels(0, 0);

    /* Map View screen parameters */
    MapView.LayoutParams screenParameters = new MapView.LayoutParams(
            MapView.LayoutParams.WRAP_CONTENT, MapView.LayoutParams.WRAP_CONTENT, mGeoPoint, 0,
            0, MapView.LayoutParams.LEFT | MapView.LayoutParams.BOTTOM);

    for (GeoPoint geoPoint : geoPointsList) {
        projection.toPixels(geoPoint, dropPoint); /*
                                                   * As Overlays are not a subclass of views so
                                                   * view animation cannot …
Run Code Online (Sandbox Code Playgroud)

android overlay android-animation android-mapview

11
推荐指数
0
解决办法
3707
查看次数