ThinkGeo.com    |     Documentation    |     Premium Support

Migrating from v13 to v14

Hi,

I am trying to migrate ThinkGEO XamarinForms to MAUI, it seems the implementation has changed.
Not sure what to do to make the previous code work…

  1. Setting Current Extent
    In v13, we could set the CurrentExtent as below.
    mapView.CurrentExtent = myCustomExtent;
    In v14, CurrentExtent setter seem to be hided. How could I set it in v14?

  2. Touch/Tap event
    In v13, we have below event handlers and the args is TouchMapViewEventArgs

    mapView.MapSingleTap -= mapView_MapClick;
    mapView.MapSingleTap += mapView_MapClick;

    mapView.MapDoubleTap -= mapView_MapDoubleClick;
    mapView.MapDoubleTap += mapView_MapDoubleClick;

But in v14, I think they have changed to
mapView.SingleTap -= mapView_MapClick;
mapView.SingleTap += mapView_MapClick;

mapView.DoubleTap -= mapView_MapDoubleClick;
mapView.DoubleTap += mapView_MapDoubleClick;

However, the eventArgs SingleTapMapViewEventArgs,DoubleTapMapViewEventArgs does not have property, PointInWorldCoordinate anymore. How to retrieve this property in v14?

  1. ZoomMapTool
    In v13, we could hide the zoomMapTool by
    mapView.MapTools.ZoomMapTool.IsEnabled = false;

But in v14, mapView.MapTools.ZoomMapTool is no longer exist, how could I disable the zoomMapTool?

  1. ZoomLevelSet
    In v13, we could do
    var defaultMapScale = mapView.ZoomLevelSet.ZoomLevel12.Scale;
    but in v14, ZoomLevelSet is no longer exist, how could I do the same thing?

Thank you

Hi Jimmy,

  1. In Maui, we use MapView.CenterPoint and MapView.MapScale for the extent, it’s better than CurrentExtent especially when RotationAngle is not 0.

  2. You can use the following line to convert screen coordinates to world coordinates:
    var pointInWorldCoordinate = MapView.ToWorldCoordinate(e.X, e.Y);

In fact let me write it down and we will discuss about it and may add PointInWorldCoordiante back.

  1. in Maui, you can add ZoomMapTool in xaml like following:

         <thinkgeo:MapView Grid.Row="1" x:Name="MapView" Grid.RowSpan="2" 
                           MapRotation="0" SizeChanged="MapView_OnSizeChanged">
             <thinkgeo:MapView.MapTools>
                 <thinkgeo:ZoomMapTool />
             </thinkgeo:MapView.MapTools>
         </thinkgeo:MapView>
    

ZoomMapTool is a standalone Maui component, you can just set IsVisible to show/hide it.

  1. In Maui, zoomLevelSet on MapView is a bit confusing because you can stop the map at any scale, that’s why we removed it. Now we have TileOverlay.ZoomLevelSet, which identifies the zoomlevels of the tiles, is this something you can use? Let me know your scenario and we can give you a better suggestion.

Please play with the Maui HowDoI samples : ThinkGeo / Public / Mobile Maps · GitLab, where you can find lots of good sample codes.

Thanks,
Ben

Thank you Ben.
Just got another question.
I am using XyzTileAsyncLayer in Xamarin app, but somehow in MAUI, the layer is not showing.

After some testing, it seems that Insert function is not working and have to use “Add” otherwise the map is not showing up. Am I missing something or it has a bug?

MapView.Overlays.Insert(0, layerOverlay);

Please find the attached sample.Xyz.xaml (683 Bytes) Xyz.xaml.cs (2.3 KB)

Another issue is the map is sometime not loading…It is loaded after moving the extent, but it will then behavior strange (cannot drag to move etc)
I can see the log as below

java.io.FileNotFoundException: open failed: ENOENT (No such file or directory)
[Glide] at android.os.ParcelFileDescriptor.openInternal(ParcelFileDescriptor.java:363)
[Glide] at android.os.ParcelFileDescriptor.open(ParcelFileDescriptor.java:239)
[Glide] at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1853)
[Glide] at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1773)
[Glide] at com.bumptech.glide.load.data.AssetFileDescriptorLocalUriFetcher.loadResource(AssetFileDescriptorLocalUriFetcher.java:20)
[Glide] at com.bumptech.glide.load.data.AssetFileDescriptorLocalUriFetcher.loadResource(AssetFileDescriptorLocalUriFetcher.java:11)
[Glide] at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:44)
[Glide] at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:100)
[Glide] at com.bumptech.glide.load.engine.SourceGenerator.startNextLoad(SourceGenerator.java:95)
[Glide] at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:88)
[Glide] at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:311)
[Glide] at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherFailed(DecodeJob.java:416)
[Glide] at com.bumptech.glide.load.engine.SourceGenerator.onLoadFailedInternal(SourceGenerator.java:223)
[Glide] at com.bumptech.glide.load.engine.SourceGenerator$1.onLoadFailed(SourceGenerator.java:108)
[Glide] at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.startNextOrFail(MultiModelLoader.java:167)
[Glide] at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.onLoadFailed(MultiModelLoader.java:154)
[Glide] at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:50)
[Glide] at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:100)
[Glide] at com.bumptech.glide.load.engine.SourceGenerator.startNextLoad(SourceGenerator.java:95)
[Glide] at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:88)
[Glide] at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:311)
[Glide] at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherFailed(DecodeJob.java:416)
[Glide] at com.bumptech.glide.load.engine.SourceGenerator.onLoadFailedInternal(SourceGenerator.java:223)
[Glide] at com.bumptech.glide.load.engine.SourceGenerator$1.onLoadFailed(SourceGenerator.java:108)
[Glide] at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.startNextOrFail(MultiModelLoader.java:167)
[Glide] at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.onLoadFailed(MultiModelLoader.java:154)
[Glide] at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:50)
[Glide] at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:100)
[Glide] at com.bumptech.glide.load.engine.SourceGenerator.startNextLoad(SourceGenerator.java:95)
[Glide] at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:88)
[Glide] at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:311)
[Glide] at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:280)
[Glide] at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:235)
[Glide] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
[Glide] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
[Glide] at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:424)
[Glide] at java.lang.Thread.run(Thread.java:1012)
[Glide] at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultPriorityThreadFactory$1.run(GlideExecutor.java:383)

I am using v14.2.1 with Android, not tested with iOS so far.

Thank you

Hi Jimmy,

Thanks for letting us know!

  1. It is a bug that Overlays.Insert doesn’t work. The bug is fixed in 14.3.0-beta071 and later versions, please pull the latest and have another try. (The fix is not included in the latest release v14.2.2)
  2. I couldn’t recreate the map-is-sometime-not-loading-issue, can you pull the latest version and have another try? Here are some settings you can play with:
  • change the overlay.TileType to TileType.MultiTile (it’s singleTile by default), change the tileSize to 256 or 512(default)
  • Show the tile ID on the tiles: ThinkGeoDebugger.DisplayTileId = true;
  • Show more debug info in the Output window:
    ThinkGeoDebugger.LogLevel = ThinkGeoLogLevel.All;
    ThinkGeoDebugger.LogType = ThinkGeoLogType.Rendering;

Please let us know the model or your device/emulation if you still see issue #2.

Thanks,
Ben

Thanks Ben,

It seems issue 2 is not happening in the latest beta version so far…
will keep an eye to see if it happens again.

By the way, may I know if there is any build in clustering feature in the library?
Thank you

Yes, and we have a cluster sample in HowDoI -> Vector Data Styling -> Display Cluster Points

1 Like