Google지도를 사용하여 앱을 개발 중입니다. 여기에서 경도 위도 값이 양식 서버를 가져 오는 위치에 마커를 표시하려고합니다.이 가져온 경도 및 위도 값에서 마커를 표시하려면 어떻게해야합니까? 다음 코드는 내 서버에서 경도 및 위도 값을 성공적으로 가져오고,이 가져 오기 langitude 및 위도와 함께 Google지도에 마커를 표시하려고합니다. 어떻게해야합니까?안드로이드의 Google지도에서 주어진 위치에 마커를 어떻게 표시합니까?
//java code
public class Location_Track1 extends Activity {
private static final String TAG = "Location_Track1";
private static final long INTERVAL = 1000 * 60 * 1; //1 minute
private static final long FASTEST_INTERVAL = 1000 * 60 * 1; // 1 minute
private static final float SMALLEST_DISPLACEMENT = 0.25F; //quarter of a meter
Button btnFusedLocation;
TextView tvLocation;
LocationRequest mLocationRequest;
GoogleApiClient mGoogleApiClient;
Location mCurrentLocation;
String mLastUpdateTime;
GoogleMap googleMap;
private ImageView mCurrentPointer;
private double longitude;
private double latitude;
// private ArrayList<LatLng> points; //added
private List<LatLng> points = new ArrayList<>();
Polyline line; //added
TextView tv_mobno, tv_latitude, tv_longitude, tv_time;
String getLatitude;
String getLongitude;
Button slocation;
JSONArray result = null;
ProgressDialog mProgressDialog;
ArrayList<HashMap<String, String>> arraylist;
static String CON = "CON";
JSONObject jsonobject;
JSONArray jsonarray;
private String url ="";
private static final String TAG_USER = "result";
// private static final String TAG_SNAME = "pseats";
private static final String TAG_LONG = "longitude";
private static final String TAG_LAT = "latitude";
private static final String TAG_ADDRESS = "paddress";
protected void createLocationRequest() {
mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(INTERVAL);
mLocationRequest.setFastestInterval(FASTEST_INTERVAL);
mLocationRequest.setSmallestDisplacement(SMALLEST_DISPLACEMENT); //added
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.location_track);
Log.d(TAG, "onCreate ...............................");
tv_mobno=(TextView)findViewById(R.id.textView_mob);
tv_latitude=(TextView)findViewById(R.id.textView_latitude);
tv_longitude=(TextView)findViewById(R.id.textView_longitude);
tv_time=(TextView)findViewById(R.id.textView_time);
slocation=(Button)findViewById(R.id.button_slocation);
url = "http://example.in/gmap_track.php";
// points = new ArrayList<LatLng>();
googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
.getMap();
slocation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// new DownloadJSON().execute();
new JSONParse().execute();
}
});
}
private class JSONParse extends AsyncTask<String, String, JSONObject> {
private ProgressDialog pDialog;
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(Location_Track1.this);
pDialog.setMessage("Getting Data ...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
@Override
protected JSONObject doInBackground(String... args) {
JSONParser jParser = new JSONParser();
// Getting JSON from URL
JSONObject json = jParser.getJSONFromUrl(url);
return json;
}
@Override
protected void onPostExecute(JSONObject json) {
pDialog.dismiss();
try {
// Getting JSON Array
result = json.getJSONArray(TAG_USER);
JSONObject c = result.getJSONObject(0);
// Storing JSON item in a Variable
String lat = c.getString(TAG_LAT);
String longt = c.getString(TAG_LONG);
//Set JSON Data in TextView
tv_latitude.setText(lat);
tv_longitude.setText(longt);
/* double lat = c.getDouble(TAG_LAT);
double longt = c.getDouble(TAG_LONG);
MarkerOptions marker = new MarkerOptions().position(new LatLng(lat, longt)).title("point");
googleMap.addMarker(marker);*/
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}
은 어떻게 구글 맵 형태의 서버를 가져 오는 (위도, 경도)의 JSON 값을 보여 않는 제안 나를 anyne 수 있습니까? –