0
から私は私のマーカーが地図上に表示していないSQL Serverから緯度とロング2014 wtih 100個のマーカーを追加します。私は問題が何であるか知りません。は、緯度と複数のマーカーを追加し、ロングのSQL Server 2014
これは私のコード
public class Location {
private String latlong_ID, latlong_nome;
private Double latlong_Lat, latlong_Long;
public Location(String latlong_ID, String latlong_nome,Double latlong_Lat,Double latlong_Long) {
this.latlong_ID = latlong_ID;
this.latlong_nome = latlong_nome;
this.latlong_Lat = latlong_Lat;
this.latlong_Long = latlong_Long;
}
public String getLatlong_ID() {
return latlong_ID;
}
public void setLatlong_ID(String latlong_ID) {
this.latlong_ID = latlong_ID;
}
public String getLatlong_nome() {
return latlong_nome;
}
public void setLatlong_nome(String latlong_nome) {
this.latlong_nome = latlong_nome;
}
public Double getLatlong_Lat() {
return latlong_Lat;
}
public void setLatlong_Lat(Double latlong_Lat) {
this.latlong_Lat = latlong_Lat;
}
public Double getLatlong_Long() {
return latlong_Long;
}
public void setLatlong_Long(Double latlong_Long) {
this.latlong_Long = latlong_Long;
}
}
public class LocationLatLong extends AsyncTask<String, String, String> {
String z = "";
// List<Location> locationList = new ArrayList<Location>();
@Override
protected void onPostExecute(String s) {
for(int i = 0 ; i < location.size() ; i++) {
createMarker(location.get(i).getLatlong_Lat(),location.get(i).getLatlong_Long(),location.get(i).getLatlong_nome());
}
super.onPostExecute(s);
}
@Override
protected String doInBackground(String... params) {
try {
Connection con = connectionClass.CONN();
if (con == null) {
z = "Error in connection with SQL server";
} else {
String query = "select * from LojaLocation";
PreparedStatement ps = con.prepareStatement(query);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
String LatLongID = rs.getString("Id");
String LatLongnome = rs.getString("Nome");
String LatLongLat = rs.getString("Latitude");
String LatLongLong = rs.getString("Longitudi");
Double LatLong_Lat1 = Double.valueOf(LatLongLat);
Double LatLong_Long1 = Double.valueOf(LatLongLong);
Location p = new Location(LatLongID, LatLongnome, LatLong_Lat1,LatLong_Long1);
location.add(p);
}
z = "Success";
}
} catch (Exception ex) {
z = "Error retrieving data from table";
}
return z;
}
protected void createMarker(Double latitude, Double longitude, String title) {
map.addMarker(new MarkerOptions()
.position(new LatLng(latitude, longitude))
.title(title)
.icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_map_marker)));
}
も 'zの値が何であるかcreateMarker(..)メソッド –
Iはすでに – Eudes
を追加のコードを追加します'メソッド実行の終わりに?私はコメント – Yazan