WordPress.org

Ready to get started?Download WordPress

Forums

Google map of all users locations? (15 posts)

  1. bfranker
    Member
    Posted 1 year ago #

    Hello!

    I've searched the plugins but not really having much luck.

    Is there a plugin (or combination of plugins) that would allow me to have a page showing the location of all the users of the site based only on their zip code? I'm thinking I'll need some type of plugin to do custom/extra fields during user registration (to get the zip code) and then a Google Map plugin that would look at the profiles of all the users and generate a Google Map page.

    Is this possible and if so which plugin(s) do you recommend I use? I can't seem to find one that does this.

    Thank you!

  2. pisaacs
    Member
    Posted 1 year ago #

    I'm looking for something that does that exact same thing. Has anyone come up with a solution like this?

    Floyd

  3. jasonmartin55
    Blocked
    Posted 1 year ago #

    Im looking for the same thing, if anyone does know, please post here, would be great to have something like that.

    [Moderator note: The same goes for you, "if anyone does know, please post here". Don't post in others' threads unless you're contributing towards their issue(s)]

  4. pisaacs
    Member
    Posted 1 year ago #

    Since yesterday I've been looking around for a way to do this, but so far have found nothing. At this point I'm now looking into how to build it myself, but since I'm still new to WordPress I'm not exactly familiar with the architecture of the system. My gut tells me I need to develop a custom template page and program it with calls to mt database which then format the results as JavaScript and pass them to a custom Google Map on the page. But this is just one approach, if people have other suggestions on how to approach this problem, I'd loe to hear them.

    Floyd

  5. bfranker
    Member
    Posted 1 year ago #

    I don't know how to program so can't help you but in looking around, it seems like the BuddyPress forum plugin DOES provide a Google Map that shows the location of all registered users. If somebody knows about programming maybe they can look at just that snippit of code and make it work for this.

    There are already plugins that allow extra or custom fields to be added during the registration or added in the user profile section. So, if you could just point to one of those custom/extra fields that have the "address" (or zip) then use that to build the map, i'd think that would work. But, I don't know how to code so can't do it myself. Bummer :(

    Edit: I'm not sure if the BuddyPress plugin itself does the Google Map or if I was reading about another plugin that goes with BuddyPress to do this. I suppose I could just do that but I don't really need a forum so don't want to install all that just to get a Google Map :)

  6. pisaacs
    Member
    Posted 1 year ago #

    Hey bfranker,

    Yeah I've already got the extra address fields set up to allow me to gather ther users address. Next step for me is create a custom page to pull the data out and pass it to the Google Maps API.

    The way I see this working is.

    1) Use the WP framework to query the DB and pull out the Contributors I want to highlight on the map.
    2) Formate the results and pass them to the Google Maps API
    3) Print the Google map on my page.

    Sounds easy enough.

    Right?

    Floyd

  7. bfranker
    Member
    Posted 1 year ago #

    I don't ever try to say anything sounds "easy" if I don't know how to do it. LOL

    But, yes, that seems like the basic idea I would think. Will you use something like [user map] on a page or post that would then insert the Google Map for the users in that particular post or on that particular page? I'd guess you'd also need to have a settings page that allowed you to enter the initial center of the map (optional) and the size (width and height). That's kind of the format I noticed when looking at all the other Google Map plugins.

    That would be pretty darn cool if you could come up with something! Heck, even if there are no real options initially that would work for me as all I'm really looking for is a map of the USA showing the location of maybe a couple hundred people that I could stick on a "page". :)

    Thanks!

  8. pisaacs
    Member
    Posted 1 year ago #

    My idea is to build a custom template page as a sort of one off. I started around by just creating a new template page in my custom template and then replacing the code which I got from this page . But this only gets me started. I still don't know how to get the custom meta data that I created for the location infromation yet fromt he database of even how to to use Google's GeoLocation Service to convert that to Long and Latitude information. I've done something like this in the past, but it's been a few years, so I'm sort of starting from scratch. As far as the map goes, I'm think of just using straight JavaScript.

    Floyd

  9. bfranker
    Member
    Posted 1 year ago #

    If you get something working, let me know and I'll try to test it for you!

  10. bfranker
    Member
    Posted 1 year ago #

    Any luck on figuring anything out here or did you give up? :)

    Thanks!

  11. pisaacs
    Member
    Posted 1 year ago #

    I've got a prototype working that does what I want now. But haven't had any time to work on it since last week. Basically it pulls the addresses out of the wordpress database and runs them through Google's Geolocation API to get the Longitude and Latitude coordinates as an XML feed. Once I have that, i loop through the XML and plot the contributors names and locations on the map.

    It's working fine as a proof of concept but I need to finasse it some more.

  12. bfranker
    Member
    Posted 1 year ago #

    Sounds pretty good :)

    I'm using the plugin "User Registration Aide" to allow the use of additional fields as well as force the user to input their City, State, and Zip (in separate fields). Would what you have work to "pluck" this data and make the map?

  13. pisaacs
    Member
    Posted 1 year ago #

    I did it a little more backwards. I went into the functions.php file of my theme and added the additional address information fields that way.

    Here's the code

    /////////////////////////////////////////////////////
    // Custom Field for adding user information
    /////////////////////////////////////////////////////
    add_action( 'show_user_profile', 'extra_user_profile_fields' );
    add_action( 'edit_user_profile', 'extra_user_profile_fields' );
    
    function extra_user_profile_fields( $user ) { ?>
    <h3><?php _e("Extra profile information", "blank"); ?></h3>
    
    <table class="form-table">
    <tr>
    <th><label for="address"><?php _e("Address"); ?></label></th>
    <td>
    <input type="text" name="address" id="address" value="<?php echo esc_attr( get_the_author_meta( 'address', $user->ID ) ); ?>" class="regular-text" /><br />
    <span class="description"><?php _e("Please enter your address."); ?></span>
    </td>
    </tr>
    
    <tr>
    <th><label for="city"><?php _e("City"); ?></label></th>
    <td>
    <input type="text" name="city" id="city" value="<?php echo esc_attr( get_the_author_meta( 'city', $user->ID ) ); ?>" class="regular-text" /><br />
    <span class="description"><?php _e("Please enter your city."); ?></span>
    </td>
    </tr>
    
    <tr>
    <th><label for="state"><?php _e("State"); ?></label></th>
    <td>
    <input type="text" name="state" id="province" value="<?php echo esc_attr( get_the_author_meta( 'state', $user->ID ) ); ?>" class="regular-text" /><br />
    <span class="description"><?php _e("Please enter your state."); ?></span>
    </td>
    </tr>
    
    <tr>
    <th><label for="postalcode"><?php _e("Postal Code"); ?></label></th>
    <td>
    <input type="text" name="postalcode" id="postalcode" value="<?php echo esc_attr( get_the_author_meta( 'postalcode', $user->ID ) ); ?>" class="regular-text" /><br />
    <span class="description"><?php _e("Please enter your postal code."); ?></span>
    </td>
    </tr>
    </table>
    <?php }
    
    add_action( 'personal_options_update', 'save_extra_user_profile_fields' );
    add_action( 'edit_user_profile_update', 'save_extra_user_profile_fields' );
    
    function save_extra_user_profile_fields( $user_id ) {
    
    if ( !current_user_can( 'edit_user', $user_id ) ) { return false; }
    
    update_user_meta( $user_id, 'address', $_POST['address'] );
    update_user_meta( $user_id, 'city', $_POST['city'] );
    update_user_meta( $user_id, 'state', $_POST['state'] );
    update_user_meta( $user_id, 'postalcode', $_POST['postalcode'] );
    
    }

    Then I'm using a custom page type to write in my own PHP and Javascript code. to pull it back out.

    Like I saids it's just a basic proof of concept at this point, but I'm pretty sure it will work for my needs.

    Philip

  14. bfranker
    Member
    Posted 1 year ago #

    Very cool!

    I've been reading up on some of the plugins and it seems like I might be able to use a combination of different plugins to "maybe" build a table of users with the proper info then "maybe" I can figure out how to use that to build a Google Map. I think that might be pie in the sky thinking for me to do that though. LOL

  15. conceptthegreat
    Member
    Posted 1 year ago #

    hey guys, ive been looking for something similar, im working on an online dating site and id like to be able to show all users who are currently online, aswell as *optional* be able to show location of users offline.

    I have however found a decent substitute that actually has suited my needs pretty well and may fix all of your problems. It uses ip of the user to mark where they are connecting from, it shows active users as green dots and it shows a world map you can scroll over on, the coolest feature is that is shows the users display name along with the city, state/country

    the name of plugin is "Visitor Maps and Who's Online"

    you can see a demo here on my site: goto members only portal then Members only GPS Locator http://thehotline.conceptproductionz.com
    create an account, its free, only takes a second, and will help me out with my beta testing, please feel free to use the services and spread the word.

    hope this helps

    ps - if somebody can find a google maps version of what this plugin does, thats what id like, as you know google maps can zoom down to street level etc... which this plugin cant do.

Topic Closed

This topic has been closed to new replies.

About this Topic