0
我想在MapFragment上繪製一個簡單的多邊形,但無法將其渲染。我使用developer docs的代碼示例,但無濟於事。我是新來的,所以我必須錯過一些非常明顯的東西,但我無法弄清楚它是什麼。我沒有收到任何運行時錯誤。無法在Android應用中的MapFragment上顯示多邊形
這是我主要活動的相關位。
public class UserLocation<MainActivity> extends Activity {
blah blah...
//Set up initial map fragment view
map = ((MapFragment)getFragmentManager().findFragmentById(R.id.map)).getMap();
LatLng startPoint = new LatLng(-30.89,24.26);
//See use of CameraPosition.Builder here which gives a cool perspective view on the map. See use of map.animateCamera using this method too;
CameraPosition cameraPosition = new CameraPosition.Builder().target(startPoint).tilt(60).zoom(6).bearing(0).
build();
map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
//try add polgyon
List<LatLng> points = Arrays.asList(new LatLng(18.39416, -33.97885),
new LatLng(18.45116, -33.97885),
new LatLng(18.45116, -33.91077),
new LatLng(18.39416, -33.91077),
new LatLng(18.39416, -33.97885));
PolygonOptions options = new PolygonOptions();
options.addAll(points);
options.fillColor(Color.RED);
map.addPolygon(options);
的xml文件
<TextView android:id="@+id/header" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" /> <fragment android:id="@+id/map" class="com.google.android.gms.maps.MapFragment" android:layout_width="match_parent" android:layout_height="match_parent" /> <ImageButton android:id="@+id/mainNavigationButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom" android:layout_marginLeft="120dp" android:onClick="OnClick_launch_mainNavigation" android:alpha="0.8" android:src="@drawable/copbutton"/> <Spinner android:id="@+id/spinner1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="17dp" android:entries="@array/crime_arrays" android:prompt="@string/crime_prompt" /> </FrameLayout>
的文件建議,這是一個簡單的過程,但我難倒。提前感謝您的任何建議。
男孩,這是如此簡單!這是Lat,Long訂單。太感謝了。 – andrewtrench
歡迎你。發生在我身上,花了好幾天才發現它。請將答案標記爲正確以解決問題 – longilong