use of org.activityinfo.legacy.shared.model.TileBaseMap in project activityinfo by bedatadriven.
the class BaseMapPanel method loadTileMapLabel.
private void loadTileMapLabel() {
label.setText(I18N.CONSTANTS.loading());
dispatcher.execute(new GetBaseMaps(), new AsyncCallback<BaseMapResult>() {
@Override
public void onFailure(Throwable caught) {
label.setText(value);
}
@Override
public void onSuccess(BaseMapResult result) {
for (TileBaseMap baseMap : result.getBaseMaps()) {
if (baseMap.getId().equals(value)) {
label.setText(baseMap.getName());
return;
}
}
label.setText(value);
}
});
}
use of org.activityinfo.legacy.shared.model.TileBaseMap in project activityinfo by bedatadriven.
the class MapboxLayers method toTileBaseMap.
public static TileBaseMap toTileBaseMap(BaseMap baseMap) {
if (baseMap instanceof TileBaseMap) {
return (TileBaseMap) baseMap;
} else {
String url;
if (baseMap.equals(GoogleBaseMap.ROADMAP)) {
url = MAPBOX_STREETS;
} else if (baseMap.equals(GoogleBaseMap.TERRAIN)) {
url = MAPBOX_TERRAIN;
} else if (baseMap.equals(GoogleBaseMap.SATELLITE)) {
url = MAPBOX_SATELLITE;
} else if (baseMap.equals(GoogleBaseMap.HYBRID)) {
url = MAPBOX_HYBRID;
} else {
url = MAPBOX_STREETS;
}
TileBaseMap tileBaseMap = new TileBaseMap();
tileBaseMap.setId(url);
tileBaseMap.setMinZoom(2);
tileBaseMap.setMaxZoom(18);
tileBaseMap.setTileUrlPattern(url);
return tileBaseMap;
}
}
use of org.activityinfo.legacy.shared.model.TileBaseMap in project activityinfo by bedatadriven.
the class MapGenerator method getBaseMap.
private BaseMap getBaseMap(String baseMapId) {
BaseMapResult maps = dispatcher.execute(new GetBaseMaps());
for (TileBaseMap map : maps.getBaseMaps()) {
if (map.getId().equals(baseMapId)) {
return map;
}
}
LOGGER.log(Level.SEVERE, "Could not find base map id=" + baseMapId);
return TileBaseMap.createNullMap(baseMapId);
}
use of org.activityinfo.legacy.shared.model.TileBaseMap in project activityinfo by bedatadriven.
the class ImageMapRenderer method drawBasemap.
protected void drawBasemap(MapReportElement element, TileHandler tileHandler) {
TiledMap map = createTileMap(element);
BaseMap baseMap = element.getContent().getBaseMap();
try {
if (baseMap instanceof TileBaseMap) {
drawTiledBaseMap(tileHandler, map, baseMap);
} else if (baseMap instanceof GoogleBaseMap) {
drawTiledBaseMap(tileHandler, map, MapboxLayers.toTileBaseMap(baseMap));
}
} catch (Exception e) {
LOGGER.log(Level.WARNING, "Exception drawing basemap", e);
}
}
use of org.activityinfo.legacy.shared.model.TileBaseMap in project activityinfo by bedatadriven.
the class ItextReportRendererTest method iconTest.
@Test
public void iconTest() throws IOException {
IconMapMarker marker1 = new IconMapMarker();
marker1.setIcon(MapIcon.fromEnum(Icon.Default));
marker1.setLat(-2.45);
marker1.setLng(28.8);
marker1.setX(100);
marker1.setY(100);
TileBaseMap baseMap = new TileBaseMap();
baseMap.setTileUrlPattern("//www.activityinfo.org/resources/tile/nordkivu.cd/{z}/{x}/{y}.png");
IconMapLayer layer3 = new IconMapLayer();
layer3.setIcon(MapIcon.Icon.Default.name());
layer3.getIndicatorIds().add(101);
MapContent mapContent = new MapContent();
mapContent.setFilterDescriptions(Collections.EMPTY_LIST);
mapContent.setBaseMap(baseMap);
mapContent.setZoomLevel(8);
mapContent.setCenter(new Extents(-2.2, -2.1, 28.85, 28.9).center());
mapContent.setMarkers(Arrays.asList((MapMarker) marker1));
MapReportElement map = new MapReportElement();
map.setTitle("My Map");
map.setContent(mapContent);
map.addLayer(layer3);
ReportContent content = new ReportContent();
content.setFilterDescriptions(Collections.EMPTY_LIST);
Report report = new Report();
report.setContent(content);
report.addElement(map);
renderToPdf(report, "iconMarker.pdf");
renderToHtml(report, "iconMarker.html");
renderToRtf(report, "iconMarker.rtf");
renderToImage(map, "iconMarker.png");
}
Aggregations