套疊圖片影像檔

套疊圖片影像檔

圖片影像套疊功能設定,如設定套疊圖片之大小及位置等,並可設定透明度,套疊圖片影像檔程式範例如下:

public class MainActivity extends Activity implements OnSeekBarChangeListener {

TGOnlineMap _MapView = null;

RelativeLayout AddMapView;

private static final TGLatLng KL = new TGLatLng(25.197796,121.614532);

private TGGroundOverlay mGroundOverlay;

private SeekBar mTransparencyBar;

private static final int TRANSPARENCY_MAX = 100;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

AddMapView = (RelativeLayout)findViewById(R.id.AddMapView);

try {

_MapView = new TGOnlineMap(this);

 

AddMapView.addView(_MapView);

_MapView.setBackgroundColor(Color.rgb(165,191,221));

mTransparencyBar = (SeekBar) findViewById(R.id.transparencySeekBar);

mTransparencyBar.setMax(TRANSPARENCY_MAX);

mTransparencyBar.setProgress(0);

mTransparencyBar.setOnSeekBarChangeListener(this);

 

//設定圖片的位置及大小

mGroundOverlay= _MapView.addGroundOverlay(new TGGroundOverlayOptions()

.image(TGBitmapDescriptorFactory.fromResource(R.drawable.klmap))  //設定圖片

.anchor(0, 0)  //設定圖片的原點

.position(KL, 22580f, 16000f));  //設定坐標及圖片的大小(公尺)

 

_MapView.moveViewer(TGViewerUpdateFactory.newLatLngZoom(KL, 66));  //移動畫面

} catch (TGRuntimeRemoteException e) {

e.printStackTrace();

}

}

 

@Override

public void onProgressChanged(SeekBar arg0, int progress, boolean arg2) {

if (mGroundOverlay != null) {  //Ground的透明度

mGroundOverlay.setTransparency((float) progress / (float) TRANSPARENCY_MAX);

}

}

@Override

public void onStartTrackingTouch(SeekBar arg0) {

}

@Override

public void onStopTrackingTouch(SeekBar arg0) {

_MapView.invalidate(true);

}

}

回到上方