我試着去刮網站所拿到的緯度,經度使用Jsoup,將它放在gmaps,但我得到的無效雙:「」讓緯度經度
FATAL EXCEPTION: main
Process: au.com.industryresponsetraining.map, PID: 18842
java.lang.NumberFormatException: Invalid double: ""
堆棧跟蹤,當我把它讀來
你沒有把任何默認值所以異常
除了在我的onCreate()解析的onCreate()值是我Jsoup在哪裏運行。 如果我添加類似
double myDouble;
String myString = ((EditText) findViewById(R.id.editText1)).getText().toString();
if (myString != null && !myString.equals("")) {
myDouble = Double.valueOf(myString);
} else {
myDouble = 0;
}
從here引用我的地圖在海上結束了。
我的網頁上有一個有效的緯度,它
這裏LNG是我的活動
package au.com.industryresponsetraining.map;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
String ln = "";
String lt = "";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
new Thread(new Runnable() {
@Override
public void run() {
try {
//get the Document object from the site. Enter the link of site you want to fetch
Document document = Jsoup.connect("http://www.industryresponsetraining.com.au/mdt/lat.html").get();
//Get the title of blog using title tag
//title = document.select("p").text().toString();
lt = document.select("h6").text().toString();
ln = document.select("h7").text().toString();
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
double lats = Double.valueOf(lt);
double lngs = Double.valueOf(ln);
LatLng marker = new LatLng(lats, lngs);
mMap.addMarker(new MarkerOptions().position(marker).title("my Marker"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(marker));
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(marker, 15));
}
}
實際的谷歌地圖的東西已經從developers頁面引用
登錄LN和在onMapReady值LT。也記錄在線程中的值,你會知道最新情況或使用調試器 – Raghunandan
http://stackoverflow.com/questions/18672456/java-lang-numberformatexception-invalid-double –
@IntelliJ Amiya我已閱讀該帖子,甚至refernced類似的東西和給出的結果。沒有工作 – shaggs