2
2
3
3
import android .graphics .Bitmap ;
4
4
import android .graphics .BitmapFactory ;
5
- import android .graphics .Point ;
6
5
import android .graphics .PointF ;
7
6
import android .support .v7 .app .AppCompatActivity ;
8
7
import android .os .Bundle ;
9
- import android .util .Log ;
10
8
import android .view .Menu ;
11
9
import android .view .MenuItem ;
12
10
17
15
import com .onlylemi .mapview .library .utils .MapUtils ;
18
16
19
17
import java .io .IOException ;
18
+ import java .util .ArrayList ;
20
19
import java .util .List ;
20
+ import java .util .Random ;
21
21
22
22
public class RouteLayerTestActivity extends AppCompatActivity {
23
23
@@ -40,7 +40,7 @@ protected void onCreate(Bundle savedInstanceState) {
40
40
nodesContract = TestData .getNodesContactList ();
41
41
marks = TestData .getMarks ();
42
42
marksName = TestData .getMarksName ();
43
- MapUtils .init (nodes , nodesContract );
43
+ MapUtils .init (nodes . size () , nodesContract . size () );
44
44
45
45
mapView = (MapView ) findViewById (R .id .mapview );
46
46
Bitmap bitmap = null ;
@@ -76,9 +76,6 @@ public void markIsClick(int num) {
76
76
public void onMapLoadFail () {
77
77
}
78
78
79
- @ Override
80
- public void onGetCurrentMap (Bitmap bitmap ) {
81
- }
82
79
});
83
80
}
84
81
@@ -93,8 +90,17 @@ public boolean onOptionsItemSelected(MenuItem item) {
93
90
if (mapView .isMapLoadFinish ()) {
94
91
switch (item .getItemId ()) {
95
92
case R .id .route_layer_tsp :
96
-
97
-
93
+ List <PointF > list = new ArrayList <>();
94
+ list .add (marks .get (39 ));
95
+ list .add (marks .get (new Random ().nextInt (10 )));
96
+ list .add (marks .get (new Random ().nextInt (10 ) + 10 ));
97
+ list .add (marks .get (new Random ().nextInt (10 ) + 20 ));
98
+ list .add (marks .get (new Random ().nextInt (10 ) + 9 ));
99
+ List <Integer > routeList = MapUtils .getBestPathBetweenPoints (list , nodes ,
100
+ nodesContract );
101
+ routeLayer .setNodeList (nodes );
102
+ routeLayer .setRouteList (routeList );
103
+ mapView .refresh ();
98
104
break ;
99
105
default :
100
106
break ;
0 commit comments