12 Replies Latest reply on Jun 10, 2013 8:15 PM by schamblee

    Maps in Web Viewer

    beacon10

      Title

      Maps in Web Viewer

      Post

           2 questions here: 1) is the GetMap function not available in FMP or only FMP Advanced? It is in in a couple of Starter Solutions but when I paste into my FMP, I get a message that the function isn't found. 2) I can't find a way to get Web Viewer to put a map into a smaller box centered on the address location in the box. I see it done in the starter sokutions. Do you need to define the window (function)?

        • 2. Re: Maps in Web Viewer
          beacon10

          "data:text/html,
          <style type='text/css'>
          html,body {
          overflow:hidden;
          }
          </style>
          <html>
              <head>
                  <title>NavText</title>
              </head>
              <body bgcolor='#FFFFFF' TopMargin='0' style='border:0'>
                  <iframe width='" & GetLayoutObjectAttribute ( "MapViewer" ; "width" ) - 40 &
                      "' height='" & GetLayoutObjectAttribute ( "MapViewer" ; "height" ) - 30 &
                      "' frameborder='0' scrolling='no' marginheight='0' marginwidth='0'
                      src='http://local.google.com/maps?q=" & CustInfo::Street & "," & CustInfo::City & "," & CustInfo::State & "," & CustInfo::Zipplus4  & "&amp;output=embed&iwloc=0&z=14'>
                  </iframe>
              </body>
          </html>"

                

          This worked but will it fir whatever sized box it's in? I played with the "height" and saw no result. I changed the z=14 with no result. I did save it and ran it each time with no change. How do you make the map fit the box?

          • 3. Re: Maps in Web Viewer
            schamblee

                 I modify the sample contact app. I converted the custom function GetMap into a calculation field named GetMap then place this calculation field into your web viewer.  Contacts::GetMap. Set  the calculation to returns text. also set to unstore.  Under Storage Option Click Do not store recalculate as needed.

                 This sample has the Web Viewer Name and the zoom hard coded.  "Map1" and 14.  

                 Let  (
                  [
                  address =  Substitute  (
                        Work Address 1 & " " &
                        Work Address 2 & " " &
                        Work City & " " &
                        Work State & " " &
                        Work Postal Code & " " &
                        Work Country ;
                        " " ; "+"
                        ) ;
                  size =   GetLayoutObjectAttribute ( "Map1" ; "width" ) & "x" & GetLayoutObjectAttribute ("Map1" ; "height" )
                  ] ;

                 "http://maps.google.com/maps/api/staticmap?center="
                    & address &
                     "&zoom=" & 14 &
                      "&markers="
                       & address &
                        "&size="
                         & size &
                          "&sensor=false"
                  )

                  

                  

            • 4. Re: Maps in Web Viewer
              beacon10

                   Where are "size" & "sensor" defined? How would you code it to delete the "Country" part from the code?

              • 5. Re: Maps in Web Viewer
                schamblee

                     Size is calculated in the Let statement based on the height and width of the web browser. Put " " in place of Country.  Sensor indicates if the geocoding request comes from a device with a location sensor.

                • 6. Re: Maps in Web Viewer
                  beacon10

                       I'm getting an error that "size" is not found. If I block that out, error message says "sensor" is not found.

                        

                  • 7. Re: Maps in Web Viewer
                    schamblee

                         Copy the above calculation again and repaste.  Size is in the Let statement.  Something has been left out.  You can paste your complete calculation and I review.

                    • 8. Re: Maps in Web Viewer
                      beacon10

                           I can't find the original. I searched all my links but don't remember where I got it.

                      • 9. Re: Maps in Web Viewer
                        schamblee

                             I'm talking about this calculation.   The only thing you will need to change is the Work Address 1, Work Address 2, Work City, Work State, and Work Postal Code, substitue your fields.  You need to name your webViewer to Map1.

                             Let (
                             [
                             address = Substitute (
                             Work Address 1 & " " &
                             Work Address 2 & " " &
                             Work City & " " &
                             Work State & " " &
                             Work Postal Code & " " &
                             " " ;
                             " " ; "+"
                             ) ;
                             size = GetLayoutObjectAttribute ( "Map1" ; "width" ) & "x" & GetLayoutObjectAttribute ("Map1" ; "height" )
                             ] ;

                             "http://maps.google.com/maps/api/staticmap?center="
                             & address &
                             "&zoom=" & 14 &
                             "&markers="
                             & address &
                             "&size="
                             & size &
                             "&sensor=false"
                             )

                        • 10. Re: Maps in Web Viewer
                          schamblee

                               Here is a sample app using the above calculation

                          https://www.sugarsync.com/pf/D9559058_790_967064297

                          • 11. Re: Maps in Web Viewer
                            AaronStoddard

                                 S Chamblee

                                 I followed your instructions to the letter and I still get an error message (see below).  I have 12 Advanced so I can copy the GetMap function and paste it into my Custome Functions, but I don't understand how the "Map1" work.  No matter what I do, I still get the same error.  I tried your solution and even downloaded your file and see that it works, but for some reason it is just not working for me.  Any thoughts?  I would like to just use the GetMap function as I want to use it in a few different areas but I have no clue what to use for "webViewerNamej".  Any suggestions would be great.

                                  

                            • 12. Re: Maps in Web Viewer
                              schamblee

                                   Map1 is the name of the Webviewer.  You set the webviewer name from the inspector under position tab.