Trigger marker events


In this tutorial, you’ll see how you can trigger marker events so you can execute your custom code.

Add the following code to the file “functions.php” of your theme/child theme:

Check the list of all available events!

function cspm_trigger_marker_events($default, $map_id){
	
	$output = "
		plugin_map.gmap3({
			exec: {
				name: 'marker',
				all: true,
				func: function(data){
					var marker = data.object;
					var post_id = marker.post_id;
					var markerOriginalIcon = marker.icon;
					marker.addListener('click', function(){
						alert('click');
					});
					marker.addListener('mouseover', function(){
						alert('mouseover');
					});
					marker.addListener('mouseout', function(){
						alert('mouseout');
					});
				}
			}
		});
	";
	
	echo $output;
	
}
add_filter('cspm_after_map_load', 'cspm_trigger_marker_events', 10, 2);

In the same context