Experiment with map styling.
[gpl/argeo-suite.git] / environment / org.argeo.geo.ui / src / org / argeo / support / openlayers / OpenLayersMap.java
index 6fce760aee9a42bb63a8f7a97faafc01cec947ef..9d46eacb24b8a4e9145c2c8ef7a0e23b42893d95 100644 (file)
@@ -121,7 +121,8 @@ public class OpenLayersMap extends Composite {
                                sb.append("})");
                        }
                }
-               sb.append("] })");
+               sb.append("]");
+               sb.append(" })");
                this.vectorSource = sb.toString();
                if (log.isTraceEnabled())
                        log.trace("Vector source: " + vectorSource);
@@ -131,8 +132,13 @@ public class OpenLayersMap extends Composite {
        protected void renderVectorSource() {
                if (vectorSource == null)
                        return;
-               if (isRenderCompleted())
-                       browser.evaluate("map.addLayer(new ol.layer.Vector({ source: " + vectorSource + "}));");
+               if (isRenderCompleted()) {
+//                     String style = ", style: new ol.style.Style({  image: new ol.style.Icon({ src: 'https://openlayers.org/en/latest/examples/data/icon.png' }) })";
+                       String style = "";
+                       String toEvaluate = "map.addLayer(new ol.layer.Vector({ source: " + vectorSource + style + "}));";
+                       System.out.println(toEvaluate);
+                       browser.execute(toEvaluate);
+               }
        }
 
        public void addPoint(Double lng, Double lat) {
@@ -190,12 +196,12 @@ public class OpenLayersMap extends Composite {
                                        if (centerLat != null && centerLng != null) {
                                                setCenter(centerLng, centerLat);
                                        }
-                                       if (vectorSource != null)
-                                               renderVectorSource();
-                                       if (gpxSource != null)
-                                               renderGpxSource();
                                        if (!geoJsonSources.isEmpty())
                                                renderGeoJsonSources();
+                                       if (gpxSource != null)
+                                               renderGpxSource();
+                                       if (vectorSource != null)
+                                               renderVectorSource();
                                }
                                return null;
                        } catch (Exception e) {