MapPress Pro + Formidable Pro not playing nice

Home Forums MapPress Support MapPress Pro + Formidable Pro not playing nice

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #13420
    invisionstudios
    Participant

      I’m trying to produce maps from MapPress Pro using address fields from Formidable Pro. I’m using the code described on this page in my functions.php file:
      http://formidablepro.com/how-to-create-maps-from-form-entries/

      
      <?php
      /* SHORTCODE FOR MapPress + Formidable Pro connection */
      add_shortcode('form_to_mappress', 'form_to_mappress');
      function form_to_mappress($atts) {
           extract(shortcode_atts(array(
      	      'width' => '220', 'title' => '', 'body' => '',
                    'address1' => '', 'address2' => '', 'directions' => 'none'
           ), $atts));
           $mymap = new Mappress_Map(array('width' => $width));
           $mypoi_1 = new Mappress_Poi(array('title' => $title, 'body' => $body, 'address' => $address1));
           $mypoi_1->geocode();
           $mymap->pois = array($mypoi_1);
           if($address2 != ''){
             $mypoi_2 = new Mappress_Poi(array('address' => $address2));
             $mypoi_2->geocode();
             $mymap->pois = $mypoi_2;
           }
           return $mymap->display(array('directions' => $directions));
      }
      /* END SHORTCODE MapPress */
      ?>
      

      Using MPP plugin by creating maps manually works just fine. If I try the ‘form_to_mappress’ shortcode with a hand-coded address:

      [form_to_mappress address1="1160 Gahanna Parkway, Columbus, Ohio 43230" width="400" title="Grote HQ" body="Grote Headquarters, Columbus OH USA"]
      )

      I get the same result as connecting it to the FP form, a flattened 1px high box. If I manually code the CSS div with a height value I get an empty white box.

      I’ve eliminated the possibility that it’s a plugin conflict. I tested it on a fresh install of WP with no other plugins.

      I know it’s beyond the scope of this plugin + support, but I would appreciate any thoughts on how to troubleshoot.

      #13421
      Chris
      Keymaster

        Hi,

        I don’t know if this is the problem, but I don’t see a height specified? Maybe changing this line would help:

        `$mymap = new Mappress_Map(array(‘width’ => $width, ‘height’ => ‘400px’));

        If you just need to create maps with 1 location, you can use the standard MapPress geocoding functionality instead of a custom shortcode.

        Just configure your custom fields in the MapPress settings. I think if you just use a plain-text field for the address in Formidable, it will save it to the post as a custom field.

        The only trick is triggering MapPress to automatically generate the map- there’s a section in the documentation about that.

        #13422
        invisionstudios
        Participant

          Chris,

          Thanks for the quick reply.

          I actually tried adding the height var and all it does is give the div container a height, but still no map generated.

          The problem isn’t related to Formidable. It looks like the PHP isn’t passing the vars properly. Here’s an example from the CDATA of a map using the shortcode:

          var mapdata = {"mapid":null,"width":"220","height":null,"zoom":null,"center":{"lat":0,"lng":0},

          Note the mapid, height, and zoom values are all null, and the lat/lon are both 0.

          A map created with your plugin manually for the same address:

          var mapdata = {"mapid":"1","width":"220","height":"220","zoom":13,"center":{"lat":39.990817,"lng":-82.841705},

          Sounds like there is a misplaced quote mark or comma somewhere. I’m on a Mac, sometimes characters (like “) don’t get translated correctly.

          #13425
          invisionstudios
          Participant

            I found a resolution. Apparently when I copied code from the Formidable website into Dreamweaver on the Mac it converted some characters. I’m thinking it was a double quote (“) or a single quote (‘), cause all the other code looked good.

            I copied the code from Formidable again, pasted it into BBEdit (coding text editor on the Mac that allows you to control the text encoding), re-keyed any double or single quotes, then copied & pasted into my functions.php in Dreamweaver.

            It works! Take a look here:
            http://sf12cd74.a2hosting.com/~grote/contact-us/geographical-contact-information/headquarters/

            The company contact info on the right side of the page is pulled from a Formidable Pro database, and the MapPress map uses the address in the forms data.

            Thanks so much for your help. LOVE the plugin, Chris!

            #13432
            invisionstudios
            Participant

              Okay, got the forms playing with the maps. Life is good.

              Just as an aside, I added an additional Formidable plugin (found here: http://www.eish.it/formidable-geocoder/) to grab the lat/lon of each entry and store it in the database. It should help to speed things up and limit the number of hits on the Google geocode database.

            Viewing 5 posts - 1 through 5 (of 5 total)
            • You must be logged in to reply to this topic.