-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I'd like to add a http://openlayers.org/ (OpenLayers) map to my zul page and if access some data in my viewmodel with it. This using javascript. I'm aware that there is a zk openlayers component. Since it's dead since 2012 and doesn't allow me to draw on the map using javascript, I'm not willing to use it.
So far I've got the following:
<?xml version="1.0" encoding="UTF-8"?>
<?taglib uri="http://security/util" prefix="sec" ?>
<?script src="openlayers.js" ?> <!-- The Openlayers js library, placed in the same folder as my zul page -->
<zk xmlns="http://www.zkoss.org/2005/zul" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:n="http://www.zkoss.org/2005/zk/native" xmlns:h="http://www.w3.org/1999/xhtml" xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd">
<script type="text/javascript" defer="true"><![CDATA[
var mapdiv = document.getElementById(zk.Widget.$("$map").uuid + '');
var map = new OpenLayers.Map(mapdiv);
var wms = new OpenLayers.Layer.WMS(
"OpenLayers WMS",
"http://vmap0.tiles.osgeo.org/wms/vmap0",
{'layers':'basic'} );
map.addLayer(wms);
map.zoomToMaxExtent();
window.alert("MAP: " + map);]]></script>
<window id="mainWin" apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('pathtomyVM')">
<div id="map" width="800px" height="600px" />
</window>
</zk>
I've placed the openlayers.js library file in the same folder as my zul page. But this doesn't result in any output on the rendered page. Can somebody guide me through this?
Thanks, Zkh
Why don't you try the following when creating the Map?
var map = new OpenLayers.Map(zk.Widget.$("$map").uuid);
Hi, perhaps that your javascript function is never called.
Try to put it into the zk.afterLoad 'event'
<script type="text/javascript" defer="true"><![CDATA[
zk.afterLoad( function () {
var mapdiv = document.getElementById(zk.Widget.$("$map").uuid + '');
...
});
]]></script>
Matteo
Hi, exist any way to get "Latitude/Longitude" from map or the marker clicked by user? Thanks.
Asked: 2014-09-05 13:20:12 +0800
Seen: 26 times
Last updated: Sep 22 '18
Facing issue in masking on phone [closed]
coerceFromString_ override no longer works from 6.5.1 [closed]
Execute Javascript on component visible
Is there a way to resolve view model properties as input to client side javascripts?
scrollbar listner for 2 grid [closed]
Theme javascript wpd file not found