私は地図上にピンを配置するLatLngの問題を克服できません。私は文字列配列から異なるデータ(名前、電話番号など)を使用します。私はまた、そこに緯度と経度を置く。ユーザーがlistview上の位置をクリックすると、彼は別の場所に関する情報を取得します。地図上の地位を播種する以外はすべて正常です。 座標は、文字列に文字列アレイから来る:新しいアクティビティでArrayからLatLngへの文字列を使用
<string-array name="latitude">
<item>XX.XXXXXXX</item>
<item>XX.XXXXXXX</item>
<item>XX.XXXXXXX</item>
</string-array>
<string-array name="longitude">
<item>XX.XXXXXXX</item>
<item>XX.XXXXXXX</item>
<item>XX.XXXXXXX</item>
</string-array>
私はこのようなデータを渡すと、すべてのスーパー
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String[] title = getResources().getStringArray(R.array.my_string_list);
final String name = title[position];
String[] address = getResources().getStringArray(R.array.address);
final String addressplace = adres[position];
String[] phone = getResources().getStringArray(R.array.phone);
final String phonenumber = telefon[position];
String[] lat = getResources().getStringArray(R.array.latitude);
final String infolatitude = lat[position];
String[] longi = getResources().getStringArray(R.array.longitude);
final String infolongitude = longi[position];
Intent intent = new Intent(getApplicationContext(), Contact.class);
intent.putExtra("address", addressplace);
intent.putExtra("telefon", phonenumber);
intent.putExtra("lat", infolatitude);
intent.putExtra("longi", infolongitude);
startActivity(intent);
を仕事と次のアクティビティに私は示すために、マップで緯度+ LNGを使用するようにしてくださいピン
パブリッククラスの接触活性を延び{
private double latitude;
private double longitude;
private final LatLng LOCATION =new LatLng (latitude,longitude);
private GoogleMap map;
String title;
String address;
String phone;
String lat;
String longi;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_contact);
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
map.addMarker(new MarkerOptions().position(LOCATION));
map.moveCamera(CameraUpdateFactory.newLatLngZoom(LOCATION, 15));
TextView tvTitle = (TextView)findViewById(R.id.title_text);
TextView tvAddress = (TextView)findViewById(R.id.textView1_address);
Button btn = (Button)findViewById(R.id.textView2_tel);
Bundle extras = getIntent().getExtras();
if (extras != null) {
tvTitle.setText(extras.getString("title"));
tvAdres.setText(extras.getString("address"));
btn.setText(extras.getString("phone"));
latitude = Double.parseDouble(getIntent().getStringExtra("lat"));
longitude = Double.parseDouble(getIntent().getStringExtra("longi"));
}}
ミリアンペアpは正しい場所を示していませんが、アフリカのどこかで開きます。 このコードを作成する際の援助に感謝します。
*アフリカのどこか* '0,0'はおそらく? –
'Latitude' /' longitude'が 'Contact'アクティビティの' onCreate() 'で取得した後に正しい値を持っているかどうかチェックしましたか? – x0r
座標を確認してください - 私はそれをtextviewに入れてチェックし、それはcorectlyに渡されました。コードに既にMapFragmentがあります。私はちょうどあなたを地位に入れているので、あなたの助けが必要だと思います。おかげで – Pawel