ZK Team is pleased to present to our users a preview version of a great, free, and API based ZK Add-on component – Openlayers, which integrates a powerful JavaScript Map library Openlayers.
The current version supports;
- 13 different layers including Bing, Google, OSM, WMS
- 13 different controls including MousePositon, OverviewMap, PanZoom, PanZoomBar, Panel, SelectFeature etc.
and others such as Marker, Strategy, Feature and Geometry.
ZK Version
Applicable to ZK 6.0.0+
Video Demo
This demo shows 18 Openlayers map examples which shares the same functionality and API usage as the corresponding JavaScript library. See Openlayers’ Examples
Component Usage
As demonstrated in the video, we have designed Java API based objects to manipulate ZK Openlayers components in the same way as Javascript API.
For example:
ZK version:
@Wire
private Openlayers map;
public void doAfterCompose(Window comp) throws Exception {
super.doAfterCompose(comp);
Layer shaded = new VirtualEarth("Shaded", toMap(
pair("type", VirtualEarth.Type.SHADED)));
Layer hybrid = new VirtualEarth("Hybrid", toMap(
pair("type", VirtualEarth.Type.HYBRID)));
Layer aerial = new VirtualEarth("Aerial", toMap(
pair("type", VirtualEarth.Type.AERIAL)));
map.addLayers(Arrays.asList(shaded, hybrid, aerial));
map.addControl(new LayerSwitcher());
map.setCenter(new LonLat(-110, 45), 3);
}
Javascript library version:
var map;
function init(){
map = new OpenLayers.Map("map");
var shaded = new OpenLayers.Layer.VirtualEarth("Shaded", {
type: VEMapStyle.Shaded
});
var hybrid = new OpenLayers.Layer.VirtualEarth("Hybrid", {
type: VEMapStyle.Hybrid
});
var aerial = new OpenLayers.Layer.VirtualEarth("Aerial", {
type: VEMapStyle.Aerial
});
map.addLayers([shaded, hybrid, aerial]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.setCenter(new OpenLayers.LonLat(-110, 45), 3);
}
As you can see, we instantiate a Layer Java object with its required options, which has the same options from JavaScript’s library, and specify into the map variable, ZK component, to display a Bing Map example in this case.
Note: toMap and pair methods come from a utility Java class, org.zkoss.openlayers.util.Helper in order to generate Map objects easier and more JavaScript-like.
For more examples, please refer to the demo source code of the ZK Openlayers project.
Summary
The current ZK Openlayers project is on bleeding edge, and aims to fully integrate with all of Openlayers functions into this component. So we are more than happy to hear if you are interested in contributing to this component, please fork the project on github, and then pull your changes back to this project.
Resource
- Download runnable example here.
- Visit the project home here.
Hi, been looking at this and sounds really promising. Are you planning to add support for callback events such as clicking on a marker can be read in Java?
Also been trying to implement a simple popup example such as http://openlayers.org/dev/examples/light-basic.html but without success. Any hints?
Hi Guito,
The callback events will be implemented in the future, when the project is official release.
About the popup example, the current preview version is not supported yet.
Regards,
Jumper
how to import this project in Netbeans IDE? do not understand how to add openlayers.js
I think you can import the eclipse’s project from Netbeans, and you don’t need to add the openlayers.js by yourself while using this component.
Regards,
Jumper
jumper, I have this error
org.zkoss.zk.ui.metainfo.DefinitionNotFoundException: file :/ C :/ Users…mple / multimap-mercator.zul: 4:54: Component definition not found: openlayers in [LanguageDefinition: xul / html].
how resolve this error?
Hi Diego,
It looks like the Openlayers project or the lang-addon.xml is not in your classpath.
Hi Jumper .When import the project in eclipse,take me as a project and not as a javaproyect and not Zul proyect.
Follow the 3 simple steps that I read in the readme but I can not run it because I asked for a main.
are missing something?
Hi Diego, have you installed the m2e (maven project for eclipse) plugin?
Perfect…… this component is missing for many GIS comunity. Thank you.
Hi, took several attempts and I can not run the component, I use netbeans, you can put together a very simple example so I can get started
as always thank you for your cooperation
Hi,
I have a project in which I would like to use OpenLayers but I am afraid of using your preview version.
So when the official version will be released ?
I am new to ZK. is it possible to use javascript library directly to ZK ?
(for exemple using OpenLayers but with its javascript code)
Hi Jumperchen,
THIS is exactly what I was looking for….. It works like a charme……
Only one question…….
if I want to obtain a LonLat from an onClick event (Click on Map)
How could I do that ?????
Is there a release date yet ?
Patrick
Exactly what I was looking for…….
works like a charme…….
could you provide me with an example how to obtain the
LatLon when clicking the Map?
It fires the onClick Event but then I have no Idea how to obtain the LatLon
map.addEventListener(“onClick”, new EventListener() {
public void onEvent(Event arg0) throws Exception {
// Messagebox.show(((Openlayers)arg0.getTarget()));
Messagebox.show(arg0.getName()+”|”+arg0.getData()+”|”+arg0.getPage());
System.out.println( ((MousePosition)((Openlayers)arg0.getTarget()).getControl(__mouseUUID)).toClientWidget().toJSONString());
String cUID = ((Openlayers)arg0.getTarget()).getUuid();
};
});
THANKS
Good project! But no any activity a half of a year… when we can see the new version with callback events?
Hey, great job congratulations.
Eh one built from geoserver (WMS plane) which has many Feature Type. I’m trying to get me to click feature CTITULAR value, not how, anyone can help me please
WMS wms_muni4 = new WMS(
“muni5”, “http://localhost:8085/geoserver/municipalidad/wms?”,
toMap(pair(“layers”, “municipalidad:Parcelas”),
pair(“opacity”, 0.7),
pair(“transparent”, true),
pair(“featureType”, “CTITULAR”),
pair(“isBaseLayer”, false)));
map.addLayer(wms_muni4);
Hey, great job congratulations.
Eh one built from geoserver (WMS plane) which has many Feature Type. I’m trying to get me to click feature CTITULAR value, not how, anyone can help me please.
PD: in openlayers exiting OpenLayers.Control.WMSGetFeatureInfo
WMS wms_muni4 = new WMS(
“muni5”, “http://localhost:8085/geoserver/municipalidad/wms?”,
toMap(pair(“layers”, “municipalidad:Parcelas”),
pair(“opacity”, 0.7),
pair(“transparent”, true),
pair(“featureType”, “CTITULAR”),
pair(“isBaseLayer”, false)));
map.addLayer(wms_muni4);
help please!!!!
Is it possible to move a vector in a layer?. thanks. Mono
Is there any progress ?
It would be so nice having this feature.
Hi All,
Please post the issue and feature to the issue tracker – https://github.com/zkoss/openlayers/issues
And we can follow them and discuss there.
Is there any other way to obtain a characteristic of a layer may not be from WMS and have to use another type of layer. Someone could help me.
thanks
I want to obtain onClick event to a Vector in a vectorLayer. Any suggestions?
I have the same problem when trying to load an attribute of a layer with WMS GetFeatureInfo. Is there any solution for this issue?
thanks
I couldn’t download the file, links are broken please help
Hello …
May anybody help me to find out the way to do animated zoom on the map ?
I was able to animate the pan with:
map.setOptions(toMap(pair(“panTween”, “OpenLayers.Easing.Expo.easeOut”)));
map.setOptions(toMap(pair(“panDuration”, “500”)));
I applied those rules to zoomTween and zoomDuration but it seem not to work
Thanks
Hello
I tried of running the example in net beans IDE, but give the following error: org.zkoss.zk.ui.metainfo.DefinitionNotFoundException: file :/ C :/ Users…mple / multimap-mercator.zul: 4:54: Component definition not found: openlayers in [LanguageDefinition: xul / html]
How can I add the lang-addon.xml in my classpath from net beans IDE ?
Hi
I need a basic example that integrates zk and openlayer but I need the project be created in NetBeans
Regards
Lisandro
Hi, please i need catching the markers event. How can i do?
Regards.
Nazareno