vitalidze / traccar-web

Traccar Web UI mod
http://traccar.litvak.su/
152 stars 145 forks source link

Custom marker info popup #993

Open lcatoni72 opened 7 years ago

lcatoni72 commented 7 years ago

In my custom controller I added some of my costom markers on the map. this marker are displayed correctly. Now I would like to add a custom pop-up information on mouse over event marker or event ckick, but my code below does not work. Nothing happens to click on marker or the passage of the mouse event.

 Markers  poiLayer = new Markers("poi layer");
 mapController.getMap().addLayer(poiLayer);
for (final Poi poi : result) {
                    final LonLat poiPosition = new LonLat(poi.getLongitude(), poi.getLatitude());
                    Size size = new Size(16,16);
                    Icon icon = new Icon(poi.getIconUrl(), size);
                    Marker poiMarker = new Marker(poiPosition, icon);
                    poiLayer.addMarker(poiMarker);
                    poiMarker.addBrowserEventListener(EventType.MOUSE_OVER, new MarkerBrowserEventListener() {
                        @Override
                        public void onBrowserEvent(MarkerBrowserEventListener.MarkerBrowserEvent markerBrowserEvent) {
                            GWT.log("TEST!!!!");//<-- NOT EXECUTED !!
                            popup = new FramedCloud(poi.getId().toString(), poiPosition, null, "test", null, false);
                            popup.setPanMapIfOutOfView(true);
                            popup.setAutoSize(true);
                            mapController.getMap().addPopup(popup);
                        }
                    });

                }    

Can you help me ? Thank you.

vitalidze commented 7 years ago

I have used following code to register mouse over and out events:

            marker.getEvents().register("mouseover", marker, new EventHandler() {
                @Override
                public void onHandle(EventObject eventObject) {
                    // some code to run when mouse is over
                }
            });
            marker.getEvents().register("mouseout", marker, new EventHandler() {
                @Override
                public void onHandle(EventObject eventObject) {
                    // some code to run when mouse is out
                }
            });
lcatoni72 commented 7 years ago

I already tried that code but it does not work for me I understand that the 'org.gwtopenmaps.openlayers.client.Marker' class is never used. The class 'org.gwtopenmaps.openlayers.client.feature.VectorFeature', is used for marker positions. I replied operation as in 'org.traccar.web.client.view.MapPositionRenderer' class in my controller, and now works correctly form me. Thank you.

stjsrilanka commented 7 years ago

i like to add new point layer like OpenSeaMap seamarks layer to my map points data i can get from kml/kmz file or google fusion tables map can you help me to add new points layer

vitalidze commented 7 years ago

@stjsrilanka first of all please don't resurrect old threads, which are not related with your question anyhow.

Regarding your question you need to read documentation, examples of the GWT-Openlayers library on the official web site here: http://www.gwtopenlayers.org/ Then you should be able to set it up in a similar way that it is done for OpenSeaMap layer.