GoogleMap V2无法读取在地图中显示标记的要点

时间:2014-03-17 03:53:04

标签: android map google-maps-android-api-2

我想询问我的地图,此时我的地图显示,但是无法读取纬度和经度,错误是下面的代码

package com.example.search;

import java.util.ArrayList;
import java.util.List;
import com.example.database.search.*;
import android.app.ActionBar;
import android.app.ListActivity;
import android.app.SearchManager;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.maps.*;
import com.google.android.gms.maps.model.*;
import android.support.v4.app.FragmentActivity;
import android.app.Activity;
import android.os.Bundle;
import com.google.android.gms.maps.MapFragment;

public class SearchResultsActivity extends FragmentActivity{
private DBDataSource dataSource; 
private ArrayList<Sma> values;
private TextView txtQuery;

 @Override
    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);

        setContentView(R.layout.map);

        // get the action bar
        ActionBar actionBar = getActionBar();

        // Enabling Back navigation on Action Bar icon
        actionBar.setDisplayHomeAsUpEnabled(true);
 }


 @Override
    protected void onNewIntent(Intent intent) 
 {
        setIntent(intent);
        handleIntent(intent);
 }
       /**
     * Handling intent data
     */
 private void handleIntent(Intent intent) 
 {
     // Get a handle to the Map Fragment
        if (Intent.ACTION_SEARCH.equals(intent.getAction())) 
        {                  
            // Get a handle to the Map Fragment
            GoogleMap map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();

            LatLng sydney = new LatLng(-33.867, 151.206);
                    //FROM HERE THE LatLng sydney, it not working on the map
            if(map!=null)
            map.setMyLocationEnabled(true);
            map.moveCamera(CameraUpdateFactory.newLatLngZoom(sydney, 13));

            map.addMarker(new MarkerOptions()
                    .title("Sydney")
                    .snippet("The most populous city in Australia.")
                    .position(sydney));
                   }
              }
}

任何人都可以帮助我,解决这个问题,我真的很感激。谢谢b4:D

0 个答案:

没有答案