Display Geo location Map on Page Load Geolocation WordPress Plugin
I recently installed the Geolocation WordPress Plugin on one of my private blogs to allow me to Geotag my posts with a location from wherever I might have been at the time of posting. The main feature that really stood out for me was the ability to Geotag posts using the WordPress iOS app, when writing a post from my iPhone I could Geo tag that post accurately using my phones built in GPS capabilities.
However I wasn’t entirely happy with the way that the maps were being displayed, in the current version 0.1.1 you have to hover over the the text description of the location, like below and the map will then popup on your mousehover.
I’ve changed the code of the plugin to show the map on page load, which for my use works better than the mouse over. I code is pretty hacky but it works, perhaps I could extend the plugin at a later date to allow an option to be selected in the admin on which functionality you prefer, depends on the feedback I receive from this I suppose.
To enable this on your own WordPress installation simply download the files below and drag them into the geolocation plugin folder, obviously remove the .txt extensions from the file names and replace the corresponding files within that directory. If this plugin is updated (Currently these modifications are for version 0.1.1) the files attached here wont be compatible as the code would have changed.
Download
Update (30/04/2011)
I’ve added a few options to this plugin and also moved the code over to my own github repo which you can view here https://github.com/Snaver/Geolocation, a few of the changes are:
- added the option for how you wish the map to be dislayed i.e link w/hover (default) or full map on page load. Just like this //www.snaver.net/2011/02/21/display-geo-location-map-on-page-load-geolocation-wordpress-plugin/
- Reworked javascript to allow for multiple maps per page. Modified output of HTML in the post also
- Added the ability to display all posts on a Google Map, on any page/post simply use the shortcode [geolocation_map_all]
this only works for the first post. All other post shows the hover link and no map on the page or hovered
That is true, I’ve updated the code to allow for this and more https://github.com/Snaver/Geolocation . Im now going to update the post.
Thank you very much. The code now does exactly what I want it to do. You are really amazing. I noticed that you enabled options in the plugin menu to achieve this. Your edit works and it works well.
However, the simple link with hover in the plugin (new options) doesn’t work. Just an FYI for you. Also the [geolocation_map_all] code works and it works well. It would be cool if when you clicked on the icon and the post title shows, it links you to the post. As of now it’s just the post title
Also, the [geolocation_map_all] only does two post. I can not explain why it does these certain two. I have tried playing around with it but it just doesnt make sense. I will be looking over the code now
I’d the same problem. After some websearch I reached troubleshooting by editing the following code
replace this line at the bottom of geolocation.php
$myposts = get_posts( array( 'numberposts' => 250) );
250 is the number of posts to get. Feel free to change to your demands.
I notice that the post has to have a tag or it wont show up on the [geolocation_map_all] based on the last line of the code . . Good Plugin I will just make sure to tag my post. i will make it work
Hmm that is strange! I thought I had it all working, however you never can be 100% sure what with different environments.
To be quite honest the whole thing needs a re-write and tidying, I would also move the google maps API stuff from inside PHP to javascript using this http://googlemaps.mayzes.org/
I wonder if you would be willing to modify this and have an option to set for the map to only display based on a category name?
Seems to be working great. I will continue to test as I add more geo posts.
Can anyone help me to advise what code to add to have the geolocation in the template, versus it being above or below, I want to place it where the geolocation tag is. I cannot find the option or any info on what to paste so I can place it after the author and date written by.
I installed your extension and it works as supposed 😉
There is one question: Is it somehow possible to show only certain geolocation data only, i.e., from one trip on one map and show that with lines connecting all post data?
The [geolocation_map_all] works fine when I post from my computer, but they don’t show when I post from my iphone. However, if I log on my computer and republish my iphone posts, it works. Any thoughts?
the shortcode also causes my page to allow comments even though the option is disabled