Friday, May 18, 2018

Custom Rendering and New Problems

Now that I had profile pictures for users I wanted to display them when you tapped on a pin. I thought this would be easy to do but there was no options provided with pins to display pictures. After doing some research I found out that in order to customize pins you had to render them differently on different devices. Meaning you had to write separate code for iOS and Android.

What you needed to do is write a CustomRendering class in both the Android code and iOS code that extended the MapRenderer class. The MapRenderer class is called every time the Map is changed letting you manipulate how the map, but more importantly how the pins, are presented. On Android you can customize the View that is presented when tapping on a pin and have it display the users profile picture. On iOS the view presented is cut into three parts the LeftCalloutAccessoryView, the middle view, and the RightCalloutAccessoryView. I used the left accessory view to show the profile picture and the middle to show the title of the pin.

All of this was of course not done without any problems. At this point in time a lot things that were working in the past started to break. Mainly the Geolocator plugin, which meant I couldn't get locations anymore. Most of my time was spent trying to fix this. I fixed it eventually by downgrading the plugin to a lower version and manually reinstalling the dependencies again.

No comments:

Post a Comment