- public void update_ui(AltosState state) {
-// mRangeView.setText(String.format("%6.0f m", state.range));
-// if (state.from_pad != null)
-// mBearingView.setText(String.format("%3.0f°", state.from_pad.bearing));
-// mLatitudeView.setText(pos(state.gps.lat, "N", "S"));
-// mLongitudeView.setText(pos(state.gps.lon, "W", "E"));
+ private void setupMap() {
+ mMap = mMapFragment.getMap();
+ if (mMap != null) {
+ mMap.setMyLocationEnabled(true);
+ mMap.getUiSettings().setTiltGesturesEnabled(false);
+ mMap.getUiSettings().setZoomControlsEnabled(false);
+ mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(40.8,-104.7),8));
+
+ mRocketMarker = mMap.addMarker(
+ // From: http://mapicons.nicolasmollet.com/markers/industry/military/missile-2/
+ new MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.rocket))
+ .position(new LatLng(0,0))
+ .visible(false)
+ );
+
+ mPadMarker = mMap.addMarker(
+ new MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.pad))
+ .position(new LatLng(0,0))
+ .visible(false)
+ );
+
+ mPolyline = mMap.addPolyline(
+ new PolylineOptions().add(new LatLng(0,0), new LatLng(0,0))
+ .width(3)
+ .color(Color.BLUE)
+ .visible(false)
+ );
+
+ mapLoaded = true;
+ }
+ }
+
+ public void update_ui(AltosState state, AltosGreatCircle from_receiver) {
+ if (state.from_pad != null) {
+ mDistanceView.setText(String.format("%6.0f m", state.from_pad.distance));
+ mBearingView.setText(String.format("%3.0f°", state.from_pad.bearing));
+ }
+ mLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S"));
+ mLongitudeView.setText(AltosDroid.pos(state.gps.lon, "W", "E"));
+
+ if (mapLoaded) {
+ mRocketMarker.setPosition(new LatLng(state.gps.lat, state.gps.lon));
+ mRocketMarker.setVisible(true);
+
+ mPolyline.setPoints(Arrays.asList(new LatLng(state.pad_lat, state.pad_lon), new LatLng(state.gps.lat, state.gps.lon)));
+ mPolyline.setVisible(true);
+
+ if (state.state == AltosLib.ao_flight_pad) {
+ mPadMarker.setPosition(new LatLng(state.pad_lat, state.pad_lon));
+ mPadMarker.setVisible(true);
+ }
+ }