WordPress.org

Forums

Pronamic Google Maps
[resolved] Google maps to front end (6 posts)

  1. jnhghy
    Member
    Posted 3 years ago #

    Hi,
    Is there a way to move the options that we have in backend to the front end? I have a custom post type "Ad" so I have the google maps options in wp-admin -> ads -> add new my users will post ads to my site the thing is they won't have access to the backend, I have a template that allows them to set the post details (meta data) so I'm wondering what are the steps that I need to take to give the users the option to set the Long and Lat for theyer posts?
    From what I read the plugin functions works in the loop so can you give me some directions? on how to prepare the template for this changes?
    Thank you for your trouble!
    Jnhghy
    http://wordpress.org/extend/plugins/pronamic-google-maps/

  2. Remco Tolsma
    Member
    Plugin Author

    Posted 3 years ago #

    The Pronamic Google Maps plugin saves the GEO data in WordPress post meta fields. You could extend your frontend form with an latitude and longitude field and save this information in the meta data fields of the created custom 'ad' post.

    $id = wp_insert_post(...);
    
    update_post_meta($id, '_pronamic_google_maps_active', 'true');
    update_post_meta($id, '_pronamic_google_maps_latitude', $_POST['latitude']);
    update_post_meta($id, '_pronamic_google_maps_longitude', $_POST['longitude']);
  3. jnhghy
    Member
    Posted 3 years ago #

    Thanks for your respons,
    The thing is, that this is why I need the plugin to save the latitude and longitude using the plugin (as it does in the backend) so the user in the first step form gives me the street address, the thing is that this street address is not 100% accurate so in the 2nd step I want him to confirm his exact location, I will show him a map with a marker that is dragable, I don't need to show him the latitude and the longitude but I need him to move the marker to the right place and I will save that latitude and longitude. hope you understand my ideea now :).

  4. jnhghy
    Member
    Posted 3 years ago #

    In the front end I made some changes in the loop:
    I had a look in the code of the plugin and I tried to include it in the front page by adding:
    <?php include (ABSPATH . 'wp-content/plugins/pronamic-google-maps/views/meta-box.php'); ?>
    and this brought all the html that I need but the map is not showing - I inspected the html and I don't have the javascript that needs to fill the "pgm-canvas" <div>.
    I'll try to find the javascript and include that one too,
    Any help will be appreciated!
    Regards

  5. jnhghy
    Member
    Posted 3 years ago #

    Me again,
    I'm tring to give you as much info as I can :)
    after some tries and some changes, I added to my frontpage adimn.js file:
    pronamic-google-maps/js/admin.js
    this is the file that locates all the html elements so it can change the value of them, but I hit an error in admin.js ln: 376 "Uncaught ReferenceError: google is not defined"
    the file is working perfect in backend so I guess I need to include a nother file, any ideeas?
    Regards

  6. Remco Tolsma
    Member
    Plugin Author

    Posted 3 years ago #

    I don't think it's a very good idea to include files intended for the backend into the frontend. The chance that this will cause problems after plugin updates is quite high. I think it is better to write some custom code for your idea. The Google Developers page for Google Maps is an good place to start: https://developers.google.com/maps/documentation/javascript/tutorial. After you have collected all the required information you easily save it into the meta fields i mentioned earlier.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Pronamic Google Maps
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic