2018年12月7日 星期五

[Android]_ch9.10_繪製連續線、多邊形與圓形





[Android]_ch9.10_繪製連續線、多邊形與圓形



連續線(Polyline
建立PolylineOptions物件並給予各頂點緯經度
呼叫GoogleMap.addPolyline(PolylineOptions)後可以取得建立好的Polyline物件
多邊形(Polygon
建立PolygonOptions物件並給予各頂點緯經度
呼叫GoogleMap.addPolygon(PolygonOptions)後可以取得建立好的Polygon物件
圓形(Circle
建立CircleOptions物件並設定圓心、半徑


呼叫GoogleMap.addCircle(CircleOptions)後可以取得建立好的Circle物件


String sp2Data[]={"繪製地圖","連續線","多邊形","圓形","清除"};

        ArrayAdapter<String> sp2AA=new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_spinner_item, sp2Data);

        sp2AA.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

        sp2.setAdapter(sp2AA);

        sp2.setOnItemSelectedListener(new OnItemSelectedListener() {

@Override

public void onItemSelected(AdapterView<?> parent, View view,int position, long id) {

switch(position){



case 1:

PolylineOptions pl=new PolylineOptions();

pl.add(ypuLatLng,chuLatLng);

pl.width(5.5f);

pl.color(Color.BLUE);

pl.zIndex(2);

map.addPolyline(pl);

break;

case 2:

PolygonOptions pg=new PolygonOptions();

pg.add(chuLatLng,hcuLatLng,ypuLatLng);

pg.strokeWidth(3.5f);

pg.strokeColor(Color.BLACK);

pg.fillColor(Color.GREEN);

pg.zIndex(0);

map.addPolygon(pg);

break;

case 3:

CircleOptions co=new CircleOptions();

co.center(ypuLatLng);

co.radius(500);

co.strokeWidth(4);

co.strokeColor(Color.RED);

co.fillColor(Color.YELLOW);

co.zIndex(1);

map.addCircle(co);

break;

case 4:

map.clear();

break;

}

}

沒有留言:

張貼留言

Ether.fi Cash Card 一張所有人必備的加密貨幣信用卡   [Ether.fi Cash Card] : https://www.ether.fi/app/cash/sign-up?ref_code=d27f8523 ------國際交易所------ [Bitg...