iOS Question Creating a PDF from a Google Map

RVP

Active Member
Licensed User
Longtime User
I have an app that allows users to work with a Map adding markers. I allow them to save, retrieve and share layouts they have created with other users of the app. Now I want to give them an option to email a PDF of the map to people who don't have the app.

I have successfully built everything with one exception, I can't get the actual map to display.

Stripped down the code is:

I create a map object

B4X:
Dim PDFgmap As GoogleMap
PDFgmap.Initialize("PDFgmap", Main.ApiKey)
PDFgmap.Height = 612
PDFgmap.Width = 792
PDFgmap.MapType = gmap.MAP_TYPE_HYBRID
PDFgmap.GetUiSettings.CompassEnabled = True

Then I add the markers from the saved information to the map.

B4X:
For cntr=1 To MarkerData.Size-1
            Dim hMap,li as Map
            l1.Initialize
            hMap = MarkerData.Get(cntr)
            l1.Put("id",hMap.Get("id"))
            l1.Put("ASA",hMap.Get("asa"))
            l1.Put("Fstop",hMap.Get("fstop"))
            l1.Put("Shutter",hMap.Get("shutter"))
            l1.Put("Height",hMap.Get("height"))
            l1.Put("Distance",hMap.Get("distance"))
            l1.Put("ToLight",hMap.Get("tolight"))
            l1.Put("Candles",hMap.Get("candles"))
            l1.Put("Candelas",hMap.Get("candelas"))
            l1.Put("Notes",hMap.Get("notes"))
            l1.Put("Color",hMap.Get("color"))
            Dim t1 As Marker
              Dim mTag As Int
              mTag = hMap.Get("markerno")
            t1 = PDFgmap.AddMarker2(hMap.Get("markerlat"),hMap.Get("markerlong"),"L"&mTag,l1.Get("Color") )
            t1.Snippet = "Distance to M1: " & NumberFormat2(hMap.Get("distance"),0,2,0,True) 

        Next

Then I build my PDF File.

B4X:
Dim pcvs As Canvas
pcvs.InitializePDF(File.DirTemp,fileName,612,792)

Dim rect As Rect      
rect.Initialize(0,0,612,792)
pcvs.DrawView(PDFgmap,rect)
......

What I end up with in the PDF for the map image is a blank screen with only the Google Logo and the Compass showing. However I know the key is correct as it is the same one I am using elsewhere in the App to display and let the user work with the map.

I have tested putting an image of a map in the PDF by using the map that the app displays for the users to work with, and that shows up fine, so I know that displaying it works. But I don't want them to need to load a file, to create a PDF.

I also know my routines work to build the map as I temporarily put it into a panel and displayed it and it looks fine.

Any ideas, or suggestion on how to do what I want?
 

RVP

Active Member
Licensed User
Longtime User
I have tried various things and it looks like the only way it works, is if at some point the program requires the user to do something, i.e. I use msg2 to get a user response, then the map is displayed. If the whole process is done with no user input required, it doesn't.

I can work within that for now, but it would be nice to not have to do it.
 
Last edited:
Upvote 0
Top