Просмотр исходного кода

Update RoutePlanMapActivity.java

huyuguo лет назад: 4
Родитель
Сommit
988cf7a2ed
1 измененных файлов с 4 добавлено и 75 удалено
  1. 4 75
      app/src/main/java/com/electric/chargingpile/activity/RoutePlanMapActivity.java

+ 4 - 75
app/src/main/java/com/electric/chargingpile/activity/RoutePlanMapActivity.java

331
        rela_paopao = (RelativeLayout) findViewById(R.id.rela_paopao);
331
        rela_paopao = (RelativeLayout) findViewById(R.id.rela_paopao);
332
        ll_share_ui = (LinearLayout) findViewById(R.id.ll_share_ui);
332
        ll_share_ui = (LinearLayout) findViewById(R.id.ll_share_ui);
333
333
334
335
        iv_back = (ImageView) findViewById(R.id.iv_back);
334
        iv_back = (ImageView) findViewById(R.id.iv_back);
336
        iv_back.setOnClickListener(this);
335
        iv_back.setOnClickListener(this);
337
        tv_route_no1 = (TextView) findViewById(R.id.tv_route_no1);
336
        tv_route_no1 = (TextView) findViewById(R.id.tv_route_no1);
417
            aMapNavi.addAMapNaviListener(this);
416
            aMapNavi.addAMapNaviListener(this);
418
            aMapNavi.setUseInnerVoice(true);
417
            aMapNavi.setUseInnerVoice(true);
419
            MyLocationStyle myLocationStyle = new MyLocationStyle();
418
            MyLocationStyle myLocationStyle = new MyLocationStyle();
420
            myLocationStyle.myLocationIcon(com.amap.api.maps.model.BitmapDescriptorFactory
421
                    .fromResource(R.drawable.point_icon));// 设置小蓝点的图标
419
            myLocationStyle.myLocationIcon(com.amap.api.maps.model.BitmapDescriptorFactory.fromResource(R.drawable.point_icon));// 设置小蓝点的图标
422
            amap.setMyLocationStyle(myLocationStyle);
420
            amap.setMyLocationStyle(myLocationStyle);
423
            //获得地图的最大和最小缩放级别
421
            //获得地图的最大和最小缩放级别
424
            geocoderSearch = new GeocodeSearch(this);
422
            geocoderSearch = new GeocodeSearch(this);
594
        OkHttpUtils.get().url(url).build().execute(new StringCallback() {
592
        OkHttpUtils.get().url(url).build().execute(new StringCallback() {
595
            @Override
593
            @Override
596
            public void onError(Call call, Exception e) {
594
            public void onError(Call call, Exception e) {
597
598
            }
595
            }
599
596
600
            @Override
597
            @Override
1015
1012
1016
    @Override
1013
    @Override
1017
    public void notifyParallelRoad(int i) {
1014
    public void notifyParallelRoad(int i) {
1018
1019
    }
1015
    }
1020
1016
1021
    @Override
1017
    @Override
1022
    public void OnUpdateTrafficFacility(AMapNaviTrafficFacilityInfo[] aMapNaviTrafficFacilityInfos) {
1018
    public void OnUpdateTrafficFacility(AMapNaviTrafficFacilityInfo[] aMapNaviTrafficFacilityInfos) {
1023
1024
    }
1019
    }
1025
1020
1026
    @Override
1021
    @Override
1027
    public void updateAimlessModeStatistics(AimLessModeStat aimLessModeStat) {
1022
    public void updateAimlessModeStatistics(AimLessModeStat aimLessModeStat) {
1028
1029
    }
1023
    }
1030
1024
1031
    @Override
1025
    @Override
1032
    public void updateAimlessModeCongestionInfo(AimLessModeCongestionInfo aimLessModeCongestionInfo) {
1026
    public void updateAimlessModeCongestionInfo(AimLessModeCongestionInfo aimLessModeCongestionInfo) {
1033
1034
    }
1027
    }
1035
1028
1036
    @Override
1029
    @Override
1037
    public void onPlayRing(int i) {
1030
    public void onPlayRing(int i) {
1038
1039
    }
1031
    }
1040
1032
1041
    @Override
1033
    @Override
1042
    public void onCalculateRouteSuccess(AMapCalcRouteResult aMapCalcRouteResult) {
1034
    public void onCalculateRouteSuccess(AMapCalcRouteResult aMapCalcRouteResult) {
1043
1044
    }
1035
    }
1045
1036
1046
    @Override
1037
    @Override
1047
    public void onCalculateRouteFailure(AMapCalcRouteResult aMapCalcRouteResult) {
1038
    public void onCalculateRouteFailure(AMapCalcRouteResult aMapCalcRouteResult) {
1048
1049
    }
1039
    }
1050
1040
1051
    @Override
1041
    @Override
1052
    public void onNaviRouteNotify(AMapNaviRouteNotifyData aMapNaviRouteNotifyData) {
1042
    public void onNaviRouteNotify(AMapNaviRouteNotifyData aMapNaviRouteNotifyData) {
1053
1054
    }
1043
    }
1055
1044
1056
1045
1475
                            ll = new LatLng(Double.parseDouble(list.get(i).getPoi_wei()), Double.parseDouble(list.get(i).getPoi_jing()));
1464
                            ll = new LatLng(Double.parseDouble(list.get(i).getPoi_wei()), Double.parseDouble(list.get(i).getPoi_jing()));
1476
                        } else if (position <= 13) {
1465
                        } else if (position <= 13) {
1477
                            double dwei = Double.parseDouble(list.get(i).getPoi_wei());
1466
                            double dwei = Double.parseDouble(list.get(i).getPoi_wei());
1478
//                System.out.print("wei:"+l.get(i).getPoi_wei());
1479
                            double djing = Double.parseDouble(list.get(i).getPoi_jing());
1467
                            double djing = Double.parseDouble(list.get(i).getPoi_jing());
1480
//                System.out.println("jing:"+l.get(i).getPoi_jing());
1481
                            getGaode(djing, dwei);
1468
                            getGaode(djing, dwei);
1482
1483
                            ll = new LatLng(Double.parseDouble(gd_wei), Double.parseDouble(gd_jing));
1469
                            ll = new LatLng(Double.parseDouble(gd_wei), Double.parseDouble(gd_jing));
1484
                        }
1470
                        }
1485
                        if (String.valueOf(list.get(i).getId()).equals(p1) && !list.get(i).getSuit_car().equals("宝马") && !list.get(i).getSuit_car().equals("特斯拉")) {
1471
                        if (String.valueOf(list.get(i).getId()).equals(p1) && !list.get(i).getSuit_car().equals("宝马") && !list.get(i).getSuit_car().equals("特斯拉")) {
1761
    //
1747
    //
1762
    @Override
1748
    @Override
1763
    public void onCameraChangeFinish(CameraPosition cameraPosition) {
1749
    public void onCameraChangeFinish(CameraPosition cameraPosition) {
1764
//        LogUtils.e(currentMarker);
1765
        LogUtils.e("onCameraChangeFinish");
1766
        if (canRefreshMarker == true) {
1750
        if (canRefreshMarker == true) {
1767
            if (null != currentMarker) {
1751
            if (null != currentMarker) {
1768
                resetPreviousMarker(currentMarker);
1752
                resetPreviousMarker(currentMarker);
2332
        LatLng ll = new LatLng(Double.parseDouble(start_wei), Double.parseDouble(start_jing));
2316
        LatLng ll = new LatLng(Double.parseDouble(start_wei), Double.parseDouble(start_jing));
2333
        float distance = AMapUtils.calculateLineDistance(new LatLng(ll.latitude
2317
        float distance = AMapUtils.calculateLineDistance(new LatLng(ll.latitude
2334
                , ll.longitude), marker.getPosition());
2318
                , ll.longitude), marker.getPosition());
2335
//                                Toast.makeText(getApplicationContext(),Util.getDistance(d),Toast.LENGTH_SHORT).show();
2336
        mInfoWindowDistance.setText(Util.getDistance(distance));
2319
        mInfoWindowDistance.setText(Util.getDistance(distance));
2337
        //infowinow中站名称的显示
2320
        //infowinow中站名称的显示
2338
        TextView mInfoWindowName = infoWindow.findViewById(R.id.evsdk_tv_info_name);
2321
        TextView mInfoWindowName = infoWindow.findViewById(R.id.evsdk_tv_info_name);
2358
                routeTwo.clear();
2341
                routeTwo.clear();
2359
                routeThree.clear();
2342
                routeThree.clear();
2360
                exchangeView(1);
2343
                exchangeView(1);
2361
//                                    if (list_zhong.size() <= 3) {
2362
                if (!zhan_id.equals(p1) && !zhan_id.equals(p2) && !zhan_id.equals(p3)) {
2344
                if (!zhan_id.equals(p1) && !zhan_id.equals(p2) && !zhan_id.equals(p3)) {
2363
                    if (list_zhong.size() < 3) {
2345
                    if (list_zhong.size() < 3) {
2364
                        zhan = new Zhan();
2346
                        zhan = new Zhan();
2372
                        list_zhong.add(zhan);
2354
                        list_zhong.add(zhan);
2373
                        Log.e("size===", list_zhong.size() + "");
2355
                        Log.e("size===", list_zhong.size() + "");
2374
                        if (list_zhong.size() > 0) {
2356
                        if (list_zhong.size() > 0) {
2375
//                                                tv_navigation_route.setBackgroundResource(R.drawable.bg_route_btn_green);
2376
//                                                tv_save_route.setBackgroundResource(R.drawable.bg_route_btn_green);
2377
                            canRoute = true;
2357
                            canRoute = true;
2378
                            canSave = true;
2358
                            canSave = true;
2379
                        } else {
2359
                        } else {
2380
//                                                tv_navigation_route.setBackgroundResource(R.drawable.bg_route_btn_grey);
2381
//                                                tv_save_route.setBackgroundResource(R.drawable.bg_route_btn_grey);
2382
                            canRoute = false;
2360
                            canRoute = false;
2383
                            canSave = false;
2361
                            canSave = false;
2384
                        }
2362
                        }
2422
                            }
2400
                            }
2423
                        }
2401
                        }
2424
                        if (list_zhong.size() > 0) {
2402
                        if (list_zhong.size() > 0) {
2425
//                                                tv_navigation_route.setBackgroundResource(R.drawable.bg_route_btn_green);
2426
//                                                tv_save_route.setBackgroundResource(R.drawable.bg_route_btn_green);
2427
                            canRoute = true;
2403
                            canRoute = true;
2428
                            canSave = true;
2404
                            canSave = true;
2429
                        } else {
2405
                        } else {
2430
//                                                tv_navigation_route.setBackgroundResource(R.drawable.bg_route_btn_grey);
2431
//                                                tv_save_route.setBackgroundResource(R.drawable.bg_route_btn_grey);
2432
                            canRoute = false;
2406
                            canRoute = false;
2433
                            canSave = false;
2407
                            canSave = false;
2434
                        }
2408
                        }
2456
                    }
2430
                    }
2457
                    if (strategyFlag >= 0) {
2431
                    if (strategyFlag >= 0) {
2458
                        aMapNavi.calculateDriveRoute(startList, endList, zhongList, strategyFlag);
2432
                        aMapNavi.calculateDriveRoute(startList, endList, zhongList, strategyFlag);
2459
//                                                Toast.makeText(getApplicationContext(), "策略:" + strategyFlag, Toast.LENGTH_LONG).show();
2460
                    }
2433
                    }
2461
//                                            aMapNavi.calculateDriveRoute(startList, endList, zhongList, PathPlanningStrategy.DRIVING_MULTIPLE_ROUTES);
2462
                    dialog.show();
2434
                    dialog.show();
2463
2435
2464
                }
2436
                }
2465
//                                    }else {
2466
//                                        Toast.makeText(getApplicationContext(),"您已经选择了三个途经点",Toast.LENGTH_SHORT).show();
2467
//                                    }
2468
            }
2437
            }
2469
        });
2438
        });
2470
        LinearLayout mInfoWindow = infoWindow.findViewById(R.id.evsdk_rl_infowindow);
2439
        LinearLayout mInfoWindow = infoWindow.findViewById(R.id.evsdk_rl_infowindow);
2585
    }
2554
    }
2586
2555
2587
    private void getGaode(Double jing, Double wei) {
2556
    private void getGaode(Double jing, Double wei) {
2588
//        Log.e("jing", jing + "");
2589
//        Log.e("wei", wei + "");
2590
        double x_pi = 3.14159265358979324 * 3000.0 / 180.0;
2557
        double x_pi = 3.14159265358979324 * 3000.0 / 180.0;
2591
        double gg_lon;
2558
        double gg_lon;
2592
        double gg_lat;
2559
        double gg_lat;
2595
        double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi);
2562
        double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi);
2596
        gg_lon = z * Math.cos(theta);
2563
        gg_lon = z * Math.cos(theta);
2597
        gd_jing = String.valueOf(gg_lon);
2564
        gd_jing = String.valueOf(gg_lon);
2598
//        Log.e("gg_lon", gg_lon + "");
2599
        gg_lat = z * Math.sin(theta);
2565
        gg_lat = z * Math.sin(theta);
2600
        gd_wei = String.valueOf(gg_lat);
2566
        gd_wei = String.valueOf(gg_lat);
2601
//        Log.e("gg_lat", gg_lat + "");
2602
    }
2567
    }
2603
2568
2604
    private void showSimpleBottomSheetGrid() {
2569
    private void showSimpleBottomSheetGrid() {
2627
                        }
2592
                        }
2628
                    }
2593
                    }
2629
                }).build();
2594
                }).build();
2630
//        build.
2631
        build.show();
2595
        build.show();
2632
        iv_screenShot.setEnabled(true);
2596
        iv_screenShot.setEnabled(true);
2633
    }
2597
    }
2652
                    return;
2616
                    return;
2653
                }
2617
                }
2654
                try {
2618
                try {
2655
                    FileOutputStream fos = new FileOutputStream(
2656
                            Environment.getExternalStorageDirectory() + "/test_"
2657
                                    + sdf.format(new Date()) + ".png");
2658
                    boolean b = bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
2619
                    FileOutputStream fos = new FileOutputStream(Environment.getExternalStorageDirectory() + "/test_" + sdf.format(new Date()) + ".png");
2659
                    try {
2620
                    try {
2660
                        fos.flush();
2621
                        fos.flush();
2661
                    } catch (IOException e) {
2622
                    } catch (IOException e) {
2666
                    } catch (IOException e) {
2627
                    } catch (IOException e) {
2667
                        e.printStackTrace();
2628
                        e.printStackTrace();
2668
                    }
2629
                    }
2669
                    StringBuffer buffer = new StringBuffer();
2670
                    if (b) {
2671
//                        buffer.append("截屏成功 ");
2672
2673
                    } else {
2674
//                        buffer.append("截屏失败 ");
2675
                    }
2676
2677
2630
2678
                } catch (FileNotFoundException e) {
2631
                } catch (FileNotFoundException e) {
2679
                    e.printStackTrace();
2632
                    e.printStackTrace();
2807
        float scaleHeight = ((float) newHeight) / height;
2760
        float scaleHeight = ((float) newHeight) / height;
2808
        // 缩放图片动作
2761
        // 缩放图片动作
2809
        matrix.postScale(scaleWidth, scaleHeight);
2762
        matrix.postScale(scaleWidth, scaleHeight);
2810
        Bitmap bitmap = Bitmap.createBitmap(bgimage, 0, 0, (int) width,
2811
                (int) height, matrix, true);
2812
//        iv_2.setImageBitmap(bitmap);
2813
//        tv_2.setText(bitmap.getRowBytes() * bitmap.getHeight() + "");
2763
        Bitmap bitmap = Bitmap.createBitmap(bgimage, 0, 0, (int) width, (int) height, matrix, true);
2814
        return bitmap;
2764
        return bitmap;
2815
    }
2765
    }
2816
2766
2845
            e.printStackTrace();
2795
            e.printStackTrace();
2846
        }
2796
        }
2847
        mBitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut);
2797
        mBitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut);
2848
        Log.e("!!!", "下载图片");
2849
//        Toast.makeText(RoutePlanMapActivity.this,"保存成功",Toast.LENGTH_SHORT).show();
2850
        try {
2798
        try {
2851
            fOut.flush();
2799
            fOut.flush();
2852
        } catch (IOException e) {
2800
        } catch (IOException e) {
2869
        if (list != null && list.size() > 0) {
2817
        if (list != null && list.size() > 0) {
2870
            if (amap == null)
2818
            if (amap == null)
2871
                return;
2819
                return;
2872
//            LatLngBounds bounds = LatLngBounds.builder().include(new LatLng(boundArray[1], boundArray[0])).include(new LatLng(boundArray[3], boundArray[2])).build();
2873
//            amap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 10));
2874
        }
2820
        }
2875
    }
2821
    }
2876
2822
2894
        if (i == 1000) {
2840
        if (i == 1000) {
2895
            if (result != null && result.getRegeocodeAddress() != null
2841
            if (result != null && result.getRegeocodeAddress() != null
2896
                    && result.getRegeocodeAddress().getFormatAddress() != null) {
2842
                    && result.getRegeocodeAddress().getFormatAddress() != null) {
2897
//                tv_address.setText(result.getRegeocodeAddress().getFormatAddress());
2898
//                tv_name.setText("[当前位置]");
2899
//                rl_now.setClickable(true);
2900
                pl = result.getRegeocodeAddress().getPois();
2843
                pl = result.getRegeocodeAddress().getPois();
2901
                if (tag.equals("start")) {
2844
                if (tag.equals("start")) {
2902
                    tv_start.setText(pl.get(0).getTitle());
2845
                    tv_start.setText(pl.get(0).getTitle());
2905
                    tv_end.setText(pl.get(0).getTitle());
2848
                    tv_end.setText(pl.get(0).getTitle());
2906
                    save_end_name = pl.get(0).getTitle();
2849
                    save_end_name = pl.get(0).getTitle();
2907
                }
2850
                }
2908
2909
//                adapter = new RouteSelectPointActivity.POIAdapter();
2910
//                list_poi.setAdapter(adapter);
2911
//                list_poi.setEnabled(true);
2912
2913
2914
            }
2851
            }
2915
        }
2852
        }
2916
    }
2853
    }
2926
        OkHttpUtils.get().url(url).build().execute(new StringCallback() {
2863
        OkHttpUtils.get().url(url).build().execute(new StringCallback() {
2927
            @Override
2864
            @Override
2928
            public void onError(Call call, Exception e) {
2865
            public void onError(Call call, Exception e) {
2929
2866
                e.printStackTrace();
2930
            }
2867
            }
2931
2868
2932
            @Override
2869
            @Override
2967
2904
2968
            @Override
2905
            @Override
2969
            public void onResponse(String response) {
2906
            public void onResponse(String response) {
2970
//                Log.e(TAG, "onResponse: response="+response );
2971
            }
2907
            }
2972
        });
2908
        });
2973
    }
2909
    }
3037
2973
3038
            //必须告诉AMapNavi 你最后选择的哪条路
2974
            //必须告诉AMapNavi 你最后选择的哪条路
3039
            aMapNavi.selectRouteId(routeIds[routeNum - 1]);
2975
            aMapNavi.selectRouteId(routeIds[routeNum - 1]);
3040
//                Toast.makeText(this, "导航距离:" + (aMapNavi.getNaviPaths()).get(routeIds[0]).getAllLength() + "m" + "\n" + "导航时间:" + (aMapNavi.getNaviPaths()).get(routeIds[0]).getAllTime() + "s", Toast.LENGTH_SHORT).show();
3041
//                Toast.makeText(this, "导航时间:" + (aMapNavi.getNaviPaths()).get(routeIds[2]).getStrategy() + "z", Toast.LENGTH_SHORT).show();
3042
            final List<NaviLatLng> nlll = (aMapNavi.getNaviPaths()).get(routeIds[routeNum - 1]).getCoordList();
2976
            final List<NaviLatLng> nlll = (aMapNavi.getNaviPaths()).get(routeIds[routeNum - 1]).getCoordList();
3043
3044
//                Toast.makeText(this, (aMapNavi.getNaviPaths()).get(routeIds[2]).getStrategy(), Toast.LENGTH_SHORT).show();
3045
3046
3047
            routeIndex++;
2977
            routeIndex++;
3048
2978
3049
            chooseRouteSuccess = true;
2979
            chooseRouteSuccess = true;
3065
        final zhan_list markerInfo = (zhan_list) bundle.getSerializable("info");
2995
        final zhan_list markerInfo = (zhan_list) bundle.getSerializable("info");
3066
        View infoWindow = getLayoutInflater().inflate(R.layout.evsdk_layout_infowindow, null);
2996
        View infoWindow = getLayoutInflater().inflate(R.layout.evsdk_layout_infowindow, null);
3067
        getZhanInfo(String.valueOf(markerInfo.getId()), markerInfo, marker, infoWindow);
2997
        getZhanInfo(String.valueOf(markerInfo.getId()), markerInfo, marker, infoWindow);
3068
//        routeShowPresenter.getSingleZhanInfo(String.valueOf(markerInfo.getId()), BaseConstants.DENZA_VERSION, infoWindow, marker);
3069
        try {
2998
        try {
3070
            Thread.sleep(300);
2999
            Thread.sleep(300);
3071
        } catch (InterruptedException e) {
3000
        } catch (InterruptedException e) {