久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      <legend id='0A1ye'><style id='0A1ye'><dir id='0A1ye'><q id='0A1ye'></q></dir></style></legend>

        <bdo id='0A1ye'></bdo><ul id='0A1ye'></ul>
    1. <i id='0A1ye'><tr id='0A1ye'><dt id='0A1ye'><q id='0A1ye'><span id='0A1ye'><b id='0A1ye'><form id='0A1ye'><ins id='0A1ye'></ins><ul id='0A1ye'></ul><sub id='0A1ye'></sub></form><legend id='0A1ye'></legend><bdo id='0A1ye'><pre id='0A1ye'><center id='0A1ye'></center></pre></bdo></b><th id='0A1ye'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='0A1ye'><tfoot id='0A1ye'></tfoot><dl id='0A1ye'><fieldset id='0A1ye'></fieldset></dl></div>
    2. <small id='0A1ye'></small><noframes id='0A1ye'>

    3. <tfoot id='0A1ye'></tfoot>

      在 Android 中步行/駕駛時更新位置標記并在 Googl

      Update Location Marker and draw path on Google Maps when walking/driving in Android(在 Android 中步行/駕駛時更新位置標記并在 Google 地圖上繪制路徑)
          <tbody id='Z4BFn'></tbody>
          1. <legend id='Z4BFn'><style id='Z4BFn'><dir id='Z4BFn'><q id='Z4BFn'></q></dir></style></legend>
              <tfoot id='Z4BFn'></tfoot>

              <small id='Z4BFn'></small><noframes id='Z4BFn'>

              <i id='Z4BFn'><tr id='Z4BFn'><dt id='Z4BFn'><q id='Z4BFn'><span id='Z4BFn'><b id='Z4BFn'><form id='Z4BFn'><ins id='Z4BFn'></ins><ul id='Z4BFn'></ul><sub id='Z4BFn'></sub></form><legend id='Z4BFn'></legend><bdo id='Z4BFn'><pre id='Z4BFn'><center id='Z4BFn'></center></pre></bdo></b><th id='Z4BFn'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Z4BFn'><tfoot id='Z4BFn'></tfoot><dl id='Z4BFn'><fieldset id='Z4BFn'></fieldset></dl></div>

                <bdo id='Z4BFn'></bdo><ul id='Z4BFn'></ul>
                本文介紹了在 Android 中步行/駕駛時更新位置標記并在 Google 地圖上繪制路徑的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我想創建一個類似于 Google 地圖的功能.每當有人開始步行/開車時,我都想更新我的位置標記.我正在考慮使用 LocationListner 的 onLocationChange 方法,但我不確定.我也喜歡在谷歌地圖上繪制更新位置的路徑.

                I want to create a functionality like Google Maps. I want to update my location marker whenever a person start walking/driving. I am thinking of using onLocationChange method of LocationListner but I am not sure. I also like to draw the path with updating location on the Google Maps.

                歡迎所有建議.

                ItemizedOverlay:-

                ItemizedOverlay:-

                public class LocationOverlay extends ItemizedOverlay<OverlayItem>{
                
                    private List<OverlayItem> myOverlays;
                    Path path;
                    static int cnt = -1;
                    public LocationOverlay(Drawable defaultMarker) {
                        super(boundCenterBottom(defaultMarker));
                        System.out.println("Normal...");
                        myOverlays = new ArrayList<OverlayItem>();
                    }
                
                
                    public void addOverlay(OverlayItem overlay) {
                        System.out.println("Add Overlay called");
                        myOverlays.add(overlay);
                        populate();
                            cnt++;
                    }
                
                    @Override
                    protected OverlayItem createItem(int i) {
                        return myOverlays.get(i);
                    }
                
                    public void removeItem(int i) {
                        myOverlays.remove(i);
                        populate();
                    }
                
                    @Override
                    public int size() {
                        return myOverlays.size();
                    }
                
                    @Override
                    public void draw(Canvas canvas, final MapView mapView, boolean shadow) {
                
                
                           if (shadow) {
                            paint.setDither(true);
                            paint.setColor(Color.RED);
                            paint.setStyle(Paint.Style.STROKE);
                            paint.setStrokeJoin(Paint.Join.ROUND);
                            paint.setStrokeCap(Paint.Cap.ROUND);
                            paint.setStrokeWidth(4);
                
                            path = new Path();
                            Point point1 = new Point();
                            Projection projection = mapView.getProjection();
                            if (myOverlays.size() > 1) {
                
                                System.out.println(">>>>>>>>>>>");
                
                                for (int i = 0, j=i; i < myOverlays.size(); i++) {
                                Point point1 = new Point();
                                Point point2 = new Point();
                                projection.toPixels(myOverlays.get(i).getPoint(), point1);
                
                                System.out.println(">>>>>>>>>>>");
                
                                projection.toPixels(myOverlays.get(j++).getPoint(), point2);
                                System.out.println("Point == " + j);
                
                                path.moveTo(point2.x, point2.y);
                                path.lineTo(point1.x, point1.y);
                                canvas.drawPath(path, paint);
                                super.draw(canvas, mapView, shadow);
                            }   
                            }
                        }
                        canvas.drawPath(path, paint);
                        super.draw(canvas, mapView, shadow);
                    }
                }
                

                注意 - 對于單個 locationChanged,draw 方法會被多次調用.

                -

                每當發生任何位置更改事件觸發時,我都可以繪制路線,但我在那里遇到了一個小問題.它也每次都從根目錄繪制路徑.我希望它從最后一個位置開始繪制路徑(即從最后一個位置連接到下一個位置).我附上一張圖片以便更好地理解.

                I am able to draw the route whenever there is any location changed event fire but I am facing a small problem there. Its also drawing path from root every time. I want that from last place it should start drawing the path (i.e connecting from last to next location). I am attaching one image for better understanding.

                從圖中可以看出,起點也與終點相連.我不想要這個.對此有任何想法.

                From the image you can see that the starting point is also connected to last point. I don't want this. Any idea on this.

                推薦答案

                使用 MyLocationOverlay.您需要做的就是將此疊加層添加到您的 MapView.比如:

                Current location can be easily drawn with MyLocationOverlay. What you need to do - is to add this overlay to your MapView. Something like:

                mapView.addOverlay(new MyLocationOverlay(context, mapView));
                

                默認位置點會自動繪制,一移動就會更新

                The default location dot will be drawn automatically and will be updated as soon as you move

                路線有點棘手,但仍然沒有火箭科學.您需要做的是擴展 Overlay 類并實現 draw() 邏輯.您需要跟蹤您旅行的 GeoPoints 并將它們投影到地圖上(在您的疊加層的 draw() 中,您可以向 mapView 詢問 Projection 實例 - getProjection().您可以使用此投影將 GeoPoints 映射到您的地圖坐標).一旦您擁有 GeoPoints 列表 - 您可以創建一個 Path 和在畫布上繪制此路徑

                With route it is a bit trickier, but still there is no rocket science in there. What you need to do - is to extend Overlay class and implement draw() logic. You need to keep track of GeoPoints you travelled and project them on a map (in your overlay's draw() you can ask your mapView for a Projection instance - getProjection(). You can use this projection to map GeoPoints to your map coordinates). As soon as you have list of GeoPoints - you can create a Path and draw this Path on a Canvas

                如何在地圖上繪制路徑的簡化示例(我的項目中使用了一些自定義類,但你應該明白):

                The simplified example how to draw path on a map (there are some custom classes I use in my project, but you should get an idea):

                Path path;
                
                @Override
                public void draw(Canvas canvas, final MapView mapView, boolean shadow)
                {
                    Projection proj = mapView.getProjection();
                    updatePath(mapView,proj);
                    canvas.drawPath(path, mPaint);
                }
                
                protected void updatePath(final MapView mapView, Projection proj)
                {
                    path = new Path();
                
                    proj.toPixels(mPoints.get(0).point, p);
                    path.moveTo(p.x, p.y);
                
                    for(RouteEntity.RoutePoint rp : mPoints)
                    {
                        proj.toPixels(rp.point, mPoint);
                        path.lineTo(mPoint.x, mPoint.y);
                    }
                }
                

                這篇關于在 Android 中步行/駕駛時更新位置標記并在 Google 地圖上繪制路徑的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                Help calculating X and Y from Latitude and Longitude in iPhone(幫助從 iPhone 中的緯度和經度計算 X 和 Y)
                Get user#39;s current location using GPS(使用 GPS 獲取用戶的當前位置)
                IllegalArgumentException thrown by requestLocationUpdate()(requestLocationUpdate() 拋出的 IllegalArgumentException)
                How reliable is LocationManager#39;s getLastKnownLocation and how often is it updated?(LocationManager 的 getLastKnownLocation 有多可靠,多久更新一次?)
                CLLocation returning negative speed(CLLocation 返回負速度)
                How to detect Location Provider ? GPS or Network Provider(如何檢測位置提供者?GPS 或網絡提供商)
                <i id='oX6Fh'><tr id='oX6Fh'><dt id='oX6Fh'><q id='oX6Fh'><span id='oX6Fh'><b id='oX6Fh'><form id='oX6Fh'><ins id='oX6Fh'></ins><ul id='oX6Fh'></ul><sub id='oX6Fh'></sub></form><legend id='oX6Fh'></legend><bdo id='oX6Fh'><pre id='oX6Fh'><center id='oX6Fh'></center></pre></bdo></b><th id='oX6Fh'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='oX6Fh'><tfoot id='oX6Fh'></tfoot><dl id='oX6Fh'><fieldset id='oX6Fh'></fieldset></dl></div>

                1. <tfoot id='oX6Fh'></tfoot><legend id='oX6Fh'><style id='oX6Fh'><dir id='oX6Fh'><q id='oX6Fh'></q></dir></style></legend>

                        <tbody id='oX6Fh'></tbody>
                      • <small id='oX6Fh'></small><noframes id='oX6Fh'>

                          <bdo id='oX6Fh'></bdo><ul id='oX6Fh'></ul>

                          主站蜘蛛池模板: 国产情侣激情 | 欧美综合视频在线 | 中文天堂网 | 精品欧美一区二区精品久久久 | 日韩免费av网站 | 精品亚洲一区二区三区 | 草樱av| 免费成人在线网 | 免费看一级毛片 | 久久国产精品亚洲 | 免费播放一级片 | 国产高清在线视频 | 一区二区日韩精品 | 欧美精品一区二区在线观看 | 一区视频| 99精品国产一区二区三区 | 91美女在线观看 | 免费在线观看黄视频 | 国产精品视频网址 | 欧美一区免费 | 老司机深夜福利网站 | 国产精品美女久久久久 | 极品电影院 | 欧美日韩国产精品一区 | 欧美h版 | 日本在线免费观看 | 91精品国产99 | 国产91精品久久久久久久网曝门 | 精品视频在线一区 | 91色在线视频| 欧美日韩视频在线第一区 | 亚洲精品免费在线观看 | 精品国产女人 | av网站在线看 | 超碰免费在线 | 美女视频三区 | 欧美成年网站 | 天天操天天干天天透 | 亚洲巨乳自拍在线视频 | 99国产视频 | 日韩一区二区三区视频 |