I am working on Openlayer4.
There are no marker events in the official documentation.
So can you please provide me the appropriate link or code to handle the marker events in OpenLayers 4.
Like:
Marker On Click Event
Marker Double-Click Event
Marker Right Click Event
Marker Mouse Hover Event
Related
I've implemented a click event on the map using
google.maps.event.addListener(map, 'click', mapclick);
and everything is working fine.
I've also added a geojson layer on map. So, the problem is when I click on the overlay geojson layer (which is a polygon layer actually), the map click event not fired. Hence, my question is what should I do so that map click event also work when I click on an overlay layer on map?
It's not clear what you mean by "geojson layer" , but when you mean a Data-layer there are 2 options:
when you don't need the click-event to be triggered for the feature(e.g. polygon)
set the clickable-option of the layer to false:
map.data.setStyle({clickable:false});
when the click-event should be triggered for both, map and feature
trigger the event for the map programmatically:
map.data.addListener('click',function(e){
google.maps.event.trigger(this.getMap(),'click',e);
});
I want to bind a Clickevent to Markers of a GMap, which are already there when the page is loaded. So I dont want to create new Markers, i only want to bind a Click Event to existing Markers.
The Map and the Markers are already placed and now i want to do some jQuery Stuff when the user is clicking on a Marker of the map.
I only have found solutions how to create new Markers and so on. Im working with the API v3.
Is it possible to both open and infowindow and draw the route between a 'home' marker and the marker clicked?
What I've got is multiple markers on a map with a 'home' marker. I'd like to have the route drawn on the map from this 'home' marker to the marker clicked.
What you want is an event listener on your markers for the click event. Within that, use the DirectionsService to draw your route.
I am working on a website with google maps integrated.
http://www.ecompanies.nl/pilot/webdesign/breda.html
Infowindows can be opened by clicking on a map marker, or on a header link in the items listed on the right. How can I close the active infowindow before opening a new one (by clicking on a map marker, or on a header link)?
Thanks in advance.
Any help is highly appreciated.
You are creating a new infowindow for each marker. The best way to achieve what you want is to create one infowindow and share that between all the markers.
So:
Put the infowindow creation before the loop.
When you create the click event listener for the marker in the loop add infowindow.setContent('content'); before you open the marker.
this will automatically close the infowindow and open it over the new marker
In version 2 of the API the map click event returned an Overlay, LatLng, Overlaylatlng.
I used this to create a generic map event that would either retrieve the coordinates of the Map click event, or return the coordinates of a Marker or other type of Overlay.
Now that API v3 doesn't return the Overlay or Overlaylatlng during the map click event, how can I go about creating a generic "click" event for the map that works if the user clicks on a marker or overlay? I really don't want to create a click event for each marker I have on my page as I am creating anywhere from a handful to a couple thousand markers.
Also, I had to create a custom ImageMapType in order to display the StreetViewOverlay like we could do in v2 of the API because I couldn't find anywhere that told me how to add the StreetViewOverlay without the pegman icon. How can I go about retrieving the LatLng coordinates of a click on this overlay type as well?
You will need to add a click listener to each overlay you add. You can do this in a createMarker function to reduce your code overhead.
Clicks on markers do not trigger a click event on the map at all.