zoukankan      html  css  js  c++  java
  • google map 中地址转换

    1、使用Geocoder 来转换经纬度与街道地址,不过经常获取不到

    2、使用链接http://ditu.google.cn/maps/geo?output=csv&key=abcdef&q= 从网络获取

         其中output标记返回的格式,可以为 csv(用‘,’分开)、json、xml

         key 可以任意字符串

         q值如果为街道地址,则返回经纬度;如果为经纬度(用‘,’分开),则返回街道地址

    3、使用 mController.animateTo(mGeoPoint);可以定位到某一个经纬度。

    4、使用以下代码段可以再地图上添加图层

    MyLocationOverlay myLocationOverlay = new MyLocationOverlay();
    List<Overlay> list = mMapView.getOverlays();
    list.add(myLocationOverlay);
    
    class MyLocationOverlay extends Overlay
    {
        @Override
        public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when)
        {
           super.draw(canvas, mapView, shadow);
            Paint paint = new Paint();
            Point myScreenCoords = new Point();
                // 将经纬度转换成实际屏幕坐标
            mapView.getProjection().toPixels(mGeoPoint, myScreenCoords);
            paint.setStrokeWidth(1);
            paint.setARGB(255, 255, 0, 0);
            paint.setStyle(Paint.Style.STROKE);
            Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.gold);
            canvas.drawBitmap(bmp, myScreenCoords.x, myScreenCoords.y, paint);
            canvas.drawText("天府广场", myScreenCoords.x, myScreenCoords.y, paint);
            return true;
        }
    }
  • 相关阅读:
    学习Python第五天
    学习Python第三天
    Mongodb
    JMS links
    笔记整理
    a* products
    String
    business knowledge
    [Java coding] leetcode notes
    [Java Basics3] XML, Unit testing
  • 原文地址:https://www.cnblogs.com/lipeil/p/2606003.html
Copyright © 2011-2022 走看看