Actioning HTML events from outside the MAPplugin

Hi, I have a map with many Points of Interest. However, I have too much information for each POI to display in a bubble. What I would like to do is pass the information from a POI to a element outside the google map (e.g. the map object) .... this will allow me to read in the information, look up the information from the backend and display more complete information about the POI. To put this into context - if I clicked a POI on the map - I would like the sidebar to show photo, and profile fields for the assoicated user.
So I think my questions are these:
1) What is the best way of passing an POI object from the google map to html outside
2) Can someone supply some simple code showing this working?
3) Where would the best place be to put this code?


  • Vladislav


    Your options are highly dependent on the source of your POIs, so I'd really like to learn more about that and the code you possibly have. For an example, if you're using our Google Maps plugin to add your POIs (or "markers", as they're called in the plugin), the markers text will be loaded with your page too, so no need to take a back-trip to the server. If you're somehow adding them to the map dynamically, then you may want to talk to the server once the map has been loaded.

    Also, do you plan on doing the click detection yourself? Another option would be to add triggering of a custom event on marker click to the plugin. Do you think that's something you could use in your scenario?

  • jaseyb

    I have a POI for each user, they are actioned when they fill in their profile fields i.e. The google API is called to populate the address details of the map POI object

    When the front page is called, I iterate through all the users meta and add POI's to the map.

    I'm using the MapPress plugin at the moment (its very similar to yours)... code goes like this

    function jb_BuildMapDataForAllUsers()
    	// Go through all the users Meta Data and build a global Map of positions
    	global $wpdb;
    	$mymap = new Mappress_Map(array("width" => 600));
    	$user_count = $wpdb->get_results("SELECT id, display_name, user_nicename FROM " . $wpdb->base_prefix . "users WHERE user_status =0");
    	//Create an array of Map POI objects
    	$mappoi= array();
    	$c_mappoi;  //Used to store a temp Map Object.
    	foreach ( $user_count as $user)
    		//echo $user->display_name;
    		$c_mappoi =  get_user_meta( $user->id, 'jb_mappress');
    		//Check to see if the meta field exists!
    		if ( !empty($c_mappoi) )
    			//Now check if the location is 'valid' - if it is, then add to the POI
    			if ( !empty($c_mappoi[0] -> correctedAddress) )
    				array_push($mappoi, $c_mappoi[0]);
    				//echo ' title = '.$c_mappoi[0] -> title;
    	//Pass in all the Point of Interests that have been built
    	$mymap->pois = $mappoi;
    	//Display Map!
    	echo $mymap->display(array("directions"=>"none"));

    This will be displayed on the front page (for an actual example). What I think I would need to do is add some sort of listener outside of the main map object and then pass in whatever has been clicked (so i can then look up and display more information).

    Hope this make sense


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.