MapView and MapMarker issues

Hey there, several issues with MapView and MapMarkers, running on OSX + fuse 0.21.0.6650.

  1. iOS preview on device, does not show the MapMarkers at all (same applies to iOS simulator). On Android preview they are put on the map just fine. Presumably, the markers are being put on the map before the map is initialised.

  2. Both iOS preview and Android preview on devices die when live-reloading after a file save. Monitor throws the following on iOS:

ERROR: Object reference was null
    Uno.NullReferenceException occured.
       at Fuse.Controls.MapView.UpdateMarkers()
       at Fuse.Controls.MapView.DeferredMarkerUpdate()
       at Fuse.UpdateListener.Invoke()
       at Fuse.UpdateManager.Update(Fuse.Stage)
       at Fuse.UpdateManager.Update()
       at Fuse.AppBase.OnUpdate()
       at Fuse.App.OnUpdate()
       at Outracks.Simulator.Application.OnUpdate()
       at Fuse.App.OnTick(object,Uno.Platform.TimerEventArgs)
       at Uno.Platform2.Display.OnTick(Uno.Platform.TimerEventArgs)
LOG: One or more errors occurred.

and this on Android:

ERROR: Object reference was null
    Uno.NullReferenceException occured.
       at Fuse.Controls.MapView.UpdateMarkers()
       at Fuse.Controls.MapView.DeferredMarkerUpdate()
       at Fuse.UpdateListener.Invoke()
       at Fuse.UpdateManager.Update(Fuse.Stage)
       at Fuse.UpdateManager.Update()
       at Fuse.AppBase.OnUpdate()
       at Outracks.Simulator.Application.OnUpdate()
       at Fuse.App.OnFrameCallback(double,double)

Tested with the following snippet:

<App>
    <JavaScript>
    var Observable = require('FuseJS/Observable');

    // empty observable for the list
    var markers = Observable();

    // generate 5 random markers
    for (var i = 1; i < 6; i++) {
        var lat = Math.floor((Math.random() * 60) + 1);
        var lon = Math.floor((Math.random() * 90) + 1);
        var label = "test marker at " + lat + " / " + lon;
        markers.add( {'latitude':lat, 'longitude':lon, 'label':label} );
    }

    // make the markers observable available to UX
    module.exports = {
        'markers': markers
    };
    </JavaScript>

    <ClientPanel Background="#eee">
        <NativeViewHost>
            <MapView>
                <Each Items="{markers}">
                    <MapMarker Latitude="{latitude}" Longitude="{longitude}" Label="{label}" />
                </Each>
            </MapView>
        </NativeViewHost>
    </ClientPanel>

</App>

  • Somewhat unrelated and most probably reproducible - when I’m first opening an app with MapView on an iOS device thus triggering the OS Location permission request, the app dies. Same applies to app preview, as well as production build installed Ad-Hoc. Not entirely sure about the cause since I haven’t got any logs from the crash, but I wouldn’t be surprised if this was again related to MapView not being initialised on time.

Hey Uldis

The MapMarkers not showing is interesting. The way it works internally is that a kind of dummy mapview object is created until the MKMapViews’s viewDidAppear is called via a UIViewController, and then that pointer is switched to the presumably ready MapView and all the properties of the dummy is transferred over.

Do the markers fail to appear in full builds as well? There appears to me there is some discrepancy in the timing of when a property is initialized in preview vs full builds.

I’ll test thoroughly with previews today.

Andreas Rønning wrote:

Do the markers fail to appear in full builds as well?

I can’t test this because of the full builds crashing on iOS upon the MapView init when requesting Location permissions :frowning:

Awesome :frowning:

I’ll get on this, this is all new to me. The permissions thing might be the key. My device builds have always behaved nice, for what little it’s worth.