use of org.gwtopenmaps.openlayers.client.Style in project kapua by eclipse.
the class DevicesMap method placeMarkers.
private void placeMarkers(List<GwtDevice> devices) {
LonLat lonLat = null;
final List<GwtDevice> theDevices = devices;
for (int i = 0; i < devices.size(); i++) {
final GwtDevice theDevice = devices.get(i);
if (theDevice.getGpsLatitude() != null && theDevice.getGpsLongitude() != null) {
StringBuilder sbDeviceTitle = new StringBuilder();
if (theDevice.getDisplayName() != null) {
sbDeviceTitle.append(theDevice.getDisplayName()).append(" (").append(theDevice.getClientId()).append(")");
} else {
sbDeviceTitle.append(theDevice.getClientId());
}
lonLat = new LonLat(theDevice.getGpsLongitude(), theDevice.getGpsLatitude());
lonLat.transform(DEFAULT_PROJECTION.getProjectionCode(), m_map.getProjection());
// lets create a vector point on the location
Style pointStyle = new Style();
pointStyle.setFillOpacity(0.9);
pointStyle.setExternalGraphic("eclipse/org/eclipse/kapua/app/console/icon/device_map.png");
pointStyle.setGraphicSize(37, 34);
pointStyle.setGraphicOffset(-10, -34);
pointStyle.setGraphicName(theDevice.getDisplayName());
Point point = new Point(theDevice.getGpsLongitude(), theDevice.getGpsLatitude());
// transform point to OSM coordinate system
point.transform(DEFAULT_PROJECTION, new Projection(m_map.getProjection()));
VectorFeature pointFeature = new VectorFeature(point, pointStyle);
Attributes attributes = new Attributes();
attributes.setAttribute("deviceIdx", i);
pointFeature.setAttributes(attributes);
m_markerLayer.addFeature(pointFeature);
}
}
// Click SelectFeature and its Options
SelectFeatureOptions clickFeatureOptions = new SelectFeatureOptions();
clickFeatureOptions.onSelect(new SelectFeatureListener() {
@Override
public void onFeatureSelected(VectorFeature theVectorFeature) {
int deviceIdx = theVectorFeature.getAttributes().getAttributeAsInt("deviceIdx");
GwtDevice device = theDevices.get(deviceIdx);
if (device != null) {
m_devicesView.setDevice(device);
}
}
});
SelectFeature clickFeature = new SelectFeature(m_markerLayer, clickFeatureOptions);
clickFeature.setClickOut(true);
clickFeature.setMultiple(false);
// Hover SelectFeature and its Options
SelectFeatureOptions hoverFeatureOptions = new SelectFeatureOptions();
hoverFeatureOptions.setHover();
hoverFeatureOptions.setHighlightOnly(true);
hoverFeatureOptions.setRenderIntent(RenderIntent.DEFAULT);
final SelectFeature hoverFeature = new SelectFeature(m_markerLayer, hoverFeatureOptions);
hoverFeature.setClickOut(true);
hoverFeature.setMultiple(false);
hoverFeature.addFeatureHighlightedListener(new FeatureHighlightedListener() {
@Override
public void onFeatureHighlighted(VectorFeature theVectorFeature) {
int deviceIdx = theVectorFeature.getAttributes().getAttributeAsInt("deviceIdx");
GwtDevice device = theDevices.get(deviceIdx);
if (device != null) {
if (m_popup != null) {
m_map.removePopup(m_popup);
}
LonLat lonLat = theVectorFeature.getCenterLonLat();
m_popup = new AnchoredBubble("marker-info", lonLat, new Size(185, 20), "<p>" + device.getDisplayName() + " (" + device.getClientId() + ")</p>", null, false);
m_map.addPopup(m_popup);
}
}
});
hoverFeature.addFeatureUnhighlightedListener(new FeatureUnhighlightedListener() {
@Override
public void onFeatureUnhighlighted(VectorFeature eventObject) {
if (m_popup != null) {
m_map.removePopup(m_popup);
m_popup = null;
}
hoverFeature.unselectAll(null);
}
});
m_map.addControl(clickFeature);
m_map.addControl(hoverFeature);
hoverFeature.activate();
clickFeature.activate();
// auto-adjust the zoom to show all points
if (m_markerLayer.getDataExtent() != null) {
m_map.zoomToExtent(m_markerLayer.getDataExtent());
} else {
m_map.zoomTo(1);
}
}
use of org.gwtopenmaps.openlayers.client.Style in project geo-platform by geosdi.
the class GPVectorMarkerLayer method buildIconMarker.
@Override
public void buildIconMarker() {
this.style = new Style();
style.setFillOpacity(1);
setIconStyle();
style.setFontColor("blue");
style.setFontSize("13px");
style.setFontWeight("bold");
style.setLabelAlign("cb");
style.setGraphicSize(25, 41);
style.setGraphicOffset(0, -41);
}
use of org.gwtopenmaps.openlayers.client.Style in project geo-platform by geosdi.
the class VectorFeatureStyle method createStyle.
/**
* Create A Style for Vector Feature
*/
private void createStyle() {
this.vectorStyle = new Style();
vectorStyle.setStrokeColor("#000000");
vectorStyle.setStrokeWidth(1);
vectorStyle.setFillColor("#FF0000");
vectorStyle.setFillOpacity(0.5);
vectorStyle.setPointRadius(5);
vectorStyle.setStrokeOpacity(1.0);
}
use of org.gwtopenmaps.openlayers.client.Style in project geo-platform by geosdi.
the class VectorStyleProvider method get.
@Override
public Style get() {
Style vectorStyle = new Style();
vectorStyle.setStrokeColor("#000000");
vectorStyle.setStrokeWidth(1);
vectorStyle.setFillColor("#FFFF00");
vectorStyle.setFillOpacity(0.5);
vectorStyle.setPointRadius(5);
vectorStyle.setStrokeOpacity(1.0);
return vectorStyle;
}
use of org.gwtopenmaps.openlayers.client.Style in project geo-platform by geosdi.
the class PrintUtility method createRectangle.
public static Vector createRectangle(LonLat center, float scale, Map map, double sizeFactor, boolean portrait) {
Bounds extent = getExtent(center, scale, map, sizeFactor, portrait);
Geometry rect = extent.toGeometry();
VectorFeature features = new VectorFeature(rect);
Vector vectorLayer = new Vector(GPPrintWidget.PRINT_VECTOR_NAME);
vectorLayer.addFeature(features);
// Define a style for the vectors
Style style = new Style();
style.setFillColor("white");
style.setStrokeColor("violet");
style.setStrokeWidth(1);
style.setStrokeDashstyle("dash");
style.setFillOpacity(0.4);
StyleMap styleMap = new StyleMap(style);
vectorLayer.setStyleMap(styleMap);
return vectorLayer;
}
Aggregations