在 Java javafx 中为 Web 视图控制器提供 url
Serving urls to a Web view controller in Java javafx
我正在尝试使用 JavaFX 应用向 Google API 发送请求。我正在使用 Google 道路 API。问题是我要求用户导入一个带坐标的 excel 文档,该文档可以包含尽可能多的纬度和经度数据,但是 Google API 只允许少于 100 对坐标。那么我如何提供数组列表中从索引位置 0 到 99 的数据,并在按下按钮时提供从 100 到 199 或更小的下一组坐标。我目前能够提供 arraylist.sublist(0to99) 并返回 json 响应。提前致谢
//On fx button click the following happens
@FXML public void loadURL(Event event){
co_ordinates = Excel_Exchange.value;
if(!next){
limit = (int)co_ordinates.size();
next = true;//some global boolean variable so that this is done once
}
if(co_ordinates.size()<100){
StringBuilder urlCaseOne = new StringBuilder(co_ordinates.subList(start, co_ordinates.size()).toString().replaceAll("[\[\]]","").replaceAll(", ",""));
url_link = "https://roads.googleapis.com/v1/snapToRoads?path="+urlCaseOne.deleteCharAt(urlCaseOne.length()-1)+"&interpolate=true&key="+API_KEY;
}else{
if(limit>100){
StringBuilder urlCaseTwo = new StringBuilder(co_ordinates.subList(start, end).toString().replaceAll("[\[\]]","").replaceAll(", ",""));
url_link = "https://roads.googleapis.com/v1/snapToRoads?path="+urlCaseTwo.deleteCharAt(urlCaseTwo.length()-1)+"&interpolate=true&key="+API_KEY;
//System.out.println("l"+limit+" s"+start+" e"+end);
start+=100; end+=100; limit-=100;
}else if(limit<100){
StringBuilder urlCaseThree = new StringBuilder(co_ordinates.subList(start, co_ordinates.size()).toString().replaceAll("[\[\]]","").replaceAll(", ",""));
url_link = "https://roads.googleapis.com/v1/snapToRoads?path="+urlCaseThree.deleteCharAt(urlCaseThree.length()-1)+"&interpolate=true&key="+API_KEY;
}
}
//System.out.println(co_ordinates.size());
//System.out.println(url_link);
//System.out.println(co_ordinates.toString().lastIndexOf("|"));
//System.out.println(co_ordinates.subList(0, 99).size());
startLoadState.apply();
this.engine.load(url_link);
}// i have another method that navigates back by to the first url
我正在尝试使用 JavaFX 应用向 Google API 发送请求。我正在使用 Google 道路 API。问题是我要求用户导入一个带坐标的 excel 文档,该文档可以包含尽可能多的纬度和经度数据,但是 Google API 只允许少于 100 对坐标。那么我如何提供数组列表中从索引位置 0 到 99 的数据,并在按下按钮时提供从 100 到 199 或更小的下一组坐标。我目前能够提供 arraylist.sublist(0to99) 并返回 json 响应。提前致谢
//On fx button click the following happens
@FXML public void loadURL(Event event){
co_ordinates = Excel_Exchange.value;
if(!next){
limit = (int)co_ordinates.size();
next = true;//some global boolean variable so that this is done once
}
if(co_ordinates.size()<100){
StringBuilder urlCaseOne = new StringBuilder(co_ordinates.subList(start, co_ordinates.size()).toString().replaceAll("[\[\]]","").replaceAll(", ",""));
url_link = "https://roads.googleapis.com/v1/snapToRoads?path="+urlCaseOne.deleteCharAt(urlCaseOne.length()-1)+"&interpolate=true&key="+API_KEY;
}else{
if(limit>100){
StringBuilder urlCaseTwo = new StringBuilder(co_ordinates.subList(start, end).toString().replaceAll("[\[\]]","").replaceAll(", ",""));
url_link = "https://roads.googleapis.com/v1/snapToRoads?path="+urlCaseTwo.deleteCharAt(urlCaseTwo.length()-1)+"&interpolate=true&key="+API_KEY;
//System.out.println("l"+limit+" s"+start+" e"+end);
start+=100; end+=100; limit-=100;
}else if(limit<100){
StringBuilder urlCaseThree = new StringBuilder(co_ordinates.subList(start, co_ordinates.size()).toString().replaceAll("[\[\]]","").replaceAll(", ",""));
url_link = "https://roads.googleapis.com/v1/snapToRoads?path="+urlCaseThree.deleteCharAt(urlCaseThree.length()-1)+"&interpolate=true&key="+API_KEY;
}
}
//System.out.println(co_ordinates.size());
//System.out.println(url_link);
//System.out.println(co_ordinates.toString().lastIndexOf("|"));
//System.out.println(co_ordinates.subList(0, 99).size());
startLoadState.apply();
this.engine.load(url_link);
}// i have another method that navigates back by to the first url