WordPress.org

Ready to get started?Download WordPress

Forums

WP Geo
WP Geo with Google Maps v3 - Please help by testing... (29 posts)

  1. Ben Huson
    Member
    Plugin Author

    Posted 1 year ago #

    I am re-working WP Geo to work with Google Maps v3 API - their v2 API will expire on May 19, 2013.

    Please help by testing. You can download the development version here:
    https://github.com/benhuson/WP-Geo/tree/3.2.dev

    Please note this is work in progress so you will probably find some bugs so I suggest to try it on a test site.

    Please report issues here.

    Thank you

    http://wordpress.org/extend/plugins/wp-geo/

  2. Roni Marinkovic
    Member
    Posted 1 year ago #

    Hi Ben,

    I'm not able to get the map to show up, either on custom posts or all posts on a map. Code is in the source, but no map is shown. You can check my test page here: Test

    Any hints?

  3. Roni Marinkovic
    Member
    Posted 1 year ago #

    Something is missing, I get 'ReferenceError: Can't find variable: google'

  4. Roni Marinkovic
    Member
    Posted 1 year ago #

    Ok, so basically google api script was missing... If I put it in manually
    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=MYKEY&sensor=T/F"></script>
    with my api key, I get map shown for couple of seconds, and then it just disappears... ???

    btw. WP 3.5.1 (if it means anything here :-))

    ps. Would you consider using async load of script?

    function loadScript() {
            var script = document.createElement('script');
            script.type = 'text/javascript';
            script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&' +
                'callback=initialize';
            document.body.appendChild(script);
          }
    
          window.onload = loadScript;

    https://google-developers.appspot.com/maps/documentation/javascript/examples/map-simple-async

  5. Ben Huson
    Member
    Plugin Author

    Posted 1 year ago #

    @Roni Thanks for the feedback.
    Were you able to get the maps showing OK on normal posts/pages without having to add in the code manually?

    I will consider added async in the future but for now if you want to use that best just to dequeue the main script and include like that yourself.

  6. Roni Marinkovic
    Member
    Posted 1 year ago #

    Hi Ben,

    I managed to get it working. Removed manual script. It obviously took some time for Mr. G to figure out I enabled maps API v3 :-)

    Now, all is fine except for sidebar widget which does not respect the zoom level... It shows markers as expected, just the map is fully zoomed out...

    As for async loading, I might do that for now ;-)

    Great plugin btw :-)
    Thank you!

  7. Ben Huson
    Member
    Plugin Author

    Posted 1 year ago #

    @Roni Thanks for your feedback, very helpful.

  8. Roni Marinkovic
    Member
    Posted 1 year ago #

    Hi Ben,

    Sorry for posting here, if you want I can use contact form from your site, but suppose this might help others too :-)

    I'm trying to integrate map with Gravity forms. The code used to work, but now I get error:

    Fatal error: Call to a member function get_dom_id() on a non-object in /home/content/44/8697844/html/summer/wp-content/plugins/WP-Geo-3.2.dev/includes/wp-geo.php on line 768

    Any hints?

    Using this post from Gravity support.

  9. Ben Huson
    Member
    Plugin Author

    Posted 1 year ago #

    Ah, the functionality you are using there was original intended just for the admin.
    I have split out admin functionality to only load in the admin to reduce overhead.

    You could try loading the admin functionality manually like this:
    (not I have not tested this)

    function my_load_wpgeo_admin() {
       global $wpgeo;
       include_once( WPGEO_DIR . 'admin/admin.php' );
       $wpgeo->admin = new WPGeo_Admin();
    }
    add_action( 'plugins_loaded', 'my_load_wpgeo_admin' );
  10. Roni Marinkovic
    Member
    Posted 1 year ago #

    Nope, still no luck, same error.
    Tried your way, and tried to include just the file in my code since I want to it be accessible to all, not just admin.

    You can take a look at whole chunk of code at Pastebin

    Actual page with form for test.

  11. Ben Huson
    Member
    Plugin Author

    Posted 1 year ago #

    Where you do this in line 20:
    require_once( WP_PLUGIN_DIR . '/WP-Geo-3.2.dev/wp-geo.php' );

    You should be able to write it like this instead (better not to write the folder name):
    require_once( WPGEO_DIR . 'wp-geo.php' );

    Try adding the following immediately after that:
    include_once( WPGEO_DIR . 'admin/admin.php' );

    I'll also try to recreate a test later

  12. Roni Marinkovic
    Member
    Posted 1 year ago #

    Tried, I think all those combinations, but all give the same

    Fatal error: Call to a member function get_dom_id() on a non-object in /home/content/44/8697844/html/summer/wp-content/plugins/WP-Geo-3.2.dev/includes/wp-geo.php on line 768

  13. Roni Marinkovic
    Member
    Posted 1 year ago #

    Hi Ben,
    Another issue I'm having. Trying to get map for custom post in single template file.
    I can not seem to get marker for current post to show on the map.

    If I try wpgeo_map( array('width' => 630,'height' => 300) ); I get map without marker centered with default WPGeo settings.
    Same goes for get_wpgeo_map( array('width' => 630,'height' => 300) );

    If I try wpgeo_post_map(); no map shows up...
    If using echo do_shortcode("[wp_geo_map]"); no map shows up...

    Marker does show up in widget for that post (tried all combinations with and without widget on single post...

    Trying to echo wpgeo_longitude(); and echo wpgeo_latitude(); does print out correct values for current post...

    You can see at the bottom of this page a map that is zoomed and centered according to global WP Geo settings, and uder the map I printed current post wpgeo_longitude(); and wpgeo_latitude();

    Another issue:
    WP Geo widget does not respect zoom level. It is fully zoomed out!

  14. Roni Marinkovic
    Member
    Posted 1 year ago #

    Another interesting bug that I just found out...
    The page that shows mash-up map with all points shows up ok as long as I have WP Geo widget in sidebar. If I remove widget from sidebar, map does not show up.
    While the widget is in sidebar, on the mash-up map page it does not appear in sidebar, while main map is perfect... :confused:

    Code that I use to show mash-up map is:

    function gmap_loop() {
    	wpgeo_map( array(
    		'post_type' => 'accommodation',
    		'posts_per_page' => -1
    		) );
    }

    Sorry to bomb you with all of this, but I really like the plugin functionality and would love to make it all work with API v3 :-)

  15. Roni Marinkovic
    Member
    Posted 1 year ago #

    To sum it up:
    1. issue is integration with Gravity forms
    2. issue is marker to show on single posts
    3. issue is with mash-up map

    I think I found a problem for 2nd issue, in head of generated page WP Geo script is generated with post details, but first if statment says if(document.getElementById("wpgeo_map_20_1")), but the actual map id is wpgeo_map_id_1_1
    I don't know how to fix this and would not like to mess up the plugin code, but it should be pretty simple for you ;-)

  16. Roni Marinkovic
    Member
    Posted 1 year ago #

    I studied a bit issue #3 regarding mash-up map on a page (called in template via wpgeo_map).
    Checking WP Geo settings to show maps on pages resolves issue related to widget, meaning map shows up on a page as expected, with or without widget in sidebar. Ok.
    This solution is kind of not nice, since if this setting is checked, WP Geo (google maps) code appears on all pages regardless if there is a map on it or not.
    But, also unchecking checkbox to show map on Pages in settings = also big part of WP Geo code appears on all pages!

    Probably the conditions logic is mixed up a bit :-(
    My suggestion is to make a function or call that we can execute just where we want to. for example on my current project I need maps on custom post type posts, mash-up map on home page and one large mash-up map on dedicated map page. So no reason for wp geo to put all the google map script in any other pages / posts.

  17. Ben Huson
    Member
    Plugin Author

    Posted 1 year ago #

    Hi Roni,

    Thanks for all your feedback on the dev version - really helpful.
    I'll try to find time to look into all these issues soon.

    The Gravity Forms integration is a bit of a tricky one as the admin-type map required the loading of lots of things that weren't required just to show maps on the front end, so I re-factored a lot of it to only load in admin.

    I agree, there should be some sort of function so you can load manually when needed.

    Thanks

    Ben

  18. Roni Marinkovic
    Member
    Posted 1 year ago #

    Ok, posting solutions in case someone gets in same trouble ;-)

    Issue #2 solved using do shortcode in template, also in WP Geo settings, checkbox to show maps on custom post types:
    echo do_shortcode('[wpgeo_map]');

    Issue #3 solved (at least until you include that option in the plugin itself):
    a. WP Geo settings checkbox to include maps on all pages
    b. create a page with mash-up map with template (or you can use shortcode directly in that page) and placing code

    echo get_wpgeo_map( array(
    		'post_type' => 'YOUR_CUSTOM_POST_SLUG',
    		'posts_per_page' => -1
    		) );

    c. put this chunk of code in functions.php to prevent WP Geo producing scripts and includes in all pages...

    add_action('get_header', 'remove_wpgeo_scripts');
    function remove_wpgeo_scripts() {
    	if ('YOUR_CUSTOM_POST_SLUG' == get_post_type() || is_front_page()){ // include WP Geo code on custom posts where I need to show map and on front page of the site where I display map
    		return;
    	} else if ( !is_page( 'ID_OR_SLUG_OF_YOUR_MASH_UP_PAGE' ) ) { // remove WP Geo code from all except my mash-up page
    		global $wpgeo;
    		remove_action( 'wp_enqueue_scripts', array( $wpgeo, 'includeGoogleMapsJavaScriptAPI' ) );
    		remove_action( 'wp_head', array( $wpgeo, 'wp_head' ) );
    		remove_action( 'wp_footer', array( $this, 'wp_footer' ) );
    		remove_action( 'admin_footer', array( $wpgeo, 'wp_footer' ) );
    		remove_action( 'wp_enqueue_scripts', array( $wpgeo, 'enqueue_scripts' ) );
    	}
    }

    So, only issue #1 remains unsolved ;-)

  19. Ben Huson
    Member
    Plugin Author

    Posted 1 year ago #

    Roni, For issue #2 the 'wpgeo_map' shortcode essentially just calls the template function get_wpgeo_post_map() so you should be able to use:

    <?php echo get_wpgeo_post_map(); ?>

    or

    <?php echo wpgeo_post_map(); ?>

  20. Roni Marinkovic
    Member
    Posted 1 year ago #

    Yes, that works too now :-)

  21. Roni Marinkovic
    Member
    Posted 1 year ago #

  22. Ben Huson
    Member
    Plugin Author

    Posted 1 year ago #

    Consider the GitHub URl to current up to date development version:
    https://github.com/benhuson/WP-Geo/tree/3.2.dev

    I'll be moving it away from Google code over time as I have had much more useful input from people since I have hosted it on GitHub.

  23. qBart
    Member
    Posted 1 year ago #

    Installed that version (3.2dev) and it worked with V3, contrary to non-beta version with V2.
    Found two bugs so far:
    1. It nags me to update it.
    2. When I do <div id="map" style='display:none;'><?php if ( function_exists( 'wpgeo_post_map' ) ) wpgeo_post_map(); ?></div> and make the div appear, the map doesn't appear. When I remove the display:none I can toggle it just fine (make it appear and disappear).

  24. Ben Huson
    Member
    Plugin Author

    Posted 1 year ago #

    @qBart I think this is an issue whereby the Google Map is not created properly if it is initially hidden from view.

    You could try triggering a JavaScript map resize event after you show the map where 'mapname' is the Javascript ID of the map to see if that forces the map to redraw itself:

    google.maps.event.trigger(mapname, 'resize')

  25. qBart
    Member
    Posted 1 year ago #

    Thanks for the tip, I think I'll get that to work eventually indeed.
    Nothing on WP GEO's end, that is sure.

    WP GEO has stopped to work, and I get the error:
    The Google Maps API server rejected your request. The "sensor" parameter specified in the request must be set to either "true" or "false".

    Maybe it is because of something I've done, but I've changed themes and disabled all other plugins, so maybe not.
    I'll continue to try to fix.

  26. qBart
    Member
    Posted 1 year ago #

    Aaand it's gone.
    Don't know what that was.

  27. akoetsier
    Member
    Posted 1 year ago #

    Have you guys got it to work on the frontend yet ?
    I dont use gravity forms but a theme build post form.
    Any idea ?

  28. Ben Huson
    Member
    Plugin Author

    Posted 1 year ago #

    WP Geo 3.3 now release.
    Please post any new issues as a new thread.

  29. James Barlow
    Member
    Posted 1 year ago #

    For Gravity Forms, I've hacked out the code below based on the previous technique to add a map to a form. This bit doesn't actually use WP-Geo methods, but does rely on WP-Geo having correctly sorted out Google Maps API access. The result is correctly stored as a GForms entry, and as a post if you add in the required custom fields.

    This is not recommended for production sites, though, and it would probably be better to do it as enqueued javascript. But it works on my machine(tm).

    http://pastebin.com/hzfEGUke

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.