MTKView hiding ancillary views embedded in MapView?

313
5
Jump to solution
05-17-2020 11:58 AM
MichaelDavis3
Regular Contributor

After updating to 100.8 it looks like there is now a view called MTKView added to the hierarchy above the MapView.  Looks like something related to Metal rendering... anyway it seems that this new view is having the effect of masking or hiding any ancillary views you may have embedded in the MapView.  In my case I have a scale bar and floor picker that weren't showing up.  I was able to work around this by pulling those items out of the MapView in the XIB hierarchy and positioning them relative to the parent view instead.

Guess this isn't so much a question as just noting a change in functionality.

0 Kudos
1 Solution

Accepted Solutions
MichaelDavis3
Regular Contributor

I believe exportImageWithCompletion just exports the map view... the scale bar and north arrow would be ancillary elements and if you want to include them you'll probably have to add them in yourself after-the-fact. 

If your MapView and ancillary elements are all embedded in a parent UIView you might look at exporting a UIImage from that view with something like this:
https://www.hackingwithswift.com/example-code/media/how-to-render-a-uiview-to-a-uiimage 

View solution in original post

0 Kudos
5 Replies
Nicholas-Furness
Esri Regular Contributor

Yeah. We've always recommended that users do not put their view hierarchy within the AGSMapView for this precise reason - we don't know how that might get affected in the future (and the future is here ).

If we could, we would have made AGSMapView like MKMapView so that people couldn't actually set subviews on it, but Xcode/Apple don't allow that for 3rd party controls .

Fortunately the fix is not typically onerous, as I hope you found out.

MichaelDavis3
Regular Contributor

Yes - took about 10 minutes to fix up the .xib file... well worth it for the performance improvement to map drawing!

by Anonymous User
Not applicable

Hi Guys, don't know if either of you will see this posting but...  I am using the iOS SDK 100.8 and the SDK toolkit's compass and scale bar.  I think this is a similar issue or maybe related.  

My issue is with the mapView.exportImage function.  This works fine except neither the compass or the scale bar are included in the capture of the map image output. 

I see that Michael mentions pulling those items (scale bar) out of the MapView.  I had done that too (mapView.addSubview(scalebar) so moved the scale bar and compass to the VC's view (self.view.addSubview(scalebar)) as in the ESRI samples, but that made no difference.  Note that my scale bar and compass display fine on the iOS device adding the scale bar and/or compass to the mapView or view.  But the mapView.exportImage does not capture the scale bar or compass either way.  

Either of you have any suggestions? 

Thank you, Isaac 

(for Nicholas: I currently have an open Esri case)

0 Kudos
MichaelDavis3
Regular Contributor

I believe exportImageWithCompletion just exports the map view... the scale bar and north arrow would be ancillary elements and if you want to include them you'll probably have to add them in yourself after-the-fact. 

If your MapView and ancillary elements are all embedded in a parent UIView you might look at exporting a UIImage from that view with something like this:
https://www.hackingwithswift.com/example-code/media/how-to-render-a-uiview-to-a-uiimage 

View solution in original post

0 Kudos
Nicholas-Furness
Esri Regular Contributor

Mark is correct. The AGSMapView exportImage method just exports the rendered map.

I’m not sure how passing the AGSMapView through that code would work. Perhaps it’ll work just fine, but if not you might include the compass and scale bar as subviews of a single transparent overlay view that is constrained to the dimensions of the map view (but has touch interactions disabled). Then you could use the example he links to to just render those controls in a way you can easily overlay onto the exported map image, without exporting the contents of the AGSMapView itself. However, I expect that it could work just fine rendering all views together now that Runtime uses Metal.

0 Kudos