Android 在安卓系统上,是否可以使用在意向中指定的自定义标记图像向谷歌地图应用程序发送意向?
默认的谷歌地图标记是一个红色的pin。是否可以通过intent将默认标记图像替换为自定义图像 编辑:Android 在安卓系统上,是否可以使用在意向中指定的自定义标记图像向谷歌地图应用程序发送意向?,android,google-maps,android-intent,google-maps-markers,Android,Google Maps,Android Intent,Google Maps Markers,默认的谷歌地图标记是一个红色的pin。是否可以通过intent将默认标记图像替换为自定义图像 编辑: 这是发送一个打算启动外部地图应用程序的geouri时。在应用程序中使用MapActivity子类执行此操作时,则不会执行此操作。是。我只希望我正确地回答了你的问题: 您可以通过覆盖项来完成。只需查看谷歌自身的例子: 您可以通过指定可绘制标记自定义任何标记。您可以发送一个带有图像在数组中位置的整数: Intent i = new Intent (yourClass.this, MapActivit
这是发送一个打算启动外部地图应用程序的geouri时。在应用程序中使用MapActivity子类执行此操作时,则不会执行此操作。是。我只希望我正确地回答了你的问题: 您可以通过覆盖项来完成。只需查看谷歌自身的例子:
您可以通过指定可绘制标记自定义任何标记。您可以发送一个带有图像在数组中位置的整数:
Intent i = new Intent (yourClass.this, MapActivity.class)
i.putExtra("pinPosition",2);
startActivity(i);
在地图活动中:
public class MyMapActivity extends MapActivity {
private int drawables[] = { R.drawable.pin1, R.drawable.pin2, R.drawable.tutorial_pin3 };
int position;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getIntent().getSerializableExtra("pinPosition")!=null) {
position = getIntent().getSerializableExtra("pinPosition");
}
setContentView(R.layout.publish_map_activity);
map = (MapView) findViewById(R.id.mapview);
ImageView pin = (ImageView) findViewById(R.id.drag);
pin.setImageResource(drawables[position]);
....
}
}
如果您使用类似的google代码,您的xml应该是:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="@string/googlemaps_key"
android:clickable="true" />
<ImageView
android:id="@+id/drag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/contentDescription"
android:src="@drawable/mapitempng"
android:visibility="gone" />
</RelativeLayout>
谢谢您的回答。我忘了澄清我是在询问是否向外部地图应用程序发送意向。问题已编辑。感谢您的快速回答!我忘了指定我正在询问向外部地图应用程序发送意向。但我希望这能帮助那些试图在应用程序中的地图视图上使用自定义图像标记的人。