我正在研究Javafx项目,我想集成google maps,并且运行良好,现在的问题是我想通过使用地理编码获取事件地址来显示标记,并且也可以工作,但是现在,我只是静态获取它。
@Override
public void mapInitialized() {
geocodingService = new GeocodingService();
geocodingService.geocode(evs.getAdresse(),
(GeocodingResult[] results, com.lynden.gmapsfx.service.geocoding.GeocoderStatus status) -> {
LatLong l = new LatLong(results[0].getGeometry().getLocation().getLatitude(),
results[0].getGeometry().getLocation().getLongitude());
markerOptions = new MarkerOptions();
markerOptions.position(l)
.title(evs.getNomAnnonce())
.visible(true);
});
LatLong annonceLocation = new LatLong(36.858900, 10.196500);
//Set the initial properties of the map.
MapOptions mapOptions = new MapOptions();
mapOptions.center(new LatLong(36.858900, 10.196500))
.mapType(MapTypeIdEnum.ROADMAP)
.overviewMapControl(true)
.panControl(true)
.rotateControl(true)
.scaleControl(true)
.streetViewControl(true)
.zoomControl(true)
.zoom(12);
map = mapView.createMap(mapOptions);
//Add markers to the map
MarkerOptions markerOptions1 = new MarkerOptions();
markerOptions1.position(annonceLocation);
Marker AnnonceMarker = new Marker(markerOptions1);
map.addMarker( AnnonceMarker );
InfoWindowOptions infoWindowOptions = new InfoWindowOptions();
infoWindowOptions.content(evs.getDescription()+"<h2>"+evs.getNomAnnonce() +"</h2>"
+ evs.getDateDebut()
+ evs.getDateDebut());
InfoWindow fredWilkeInfoWindow = new InfoWindow(infoWindowOptions);
fredWilkeInfoWindow.open(map, AnnonceMarker);
}
结果: