Coder Social home page Coder Social logo

mapbox-xamarin-forms's Introduction

Mapbox for Xamarin.Forms

Mapbox for Xamarin.Forms

This library provides the controls/renderers for using Mapbox SDKs inside your Xamarin.Forms app.

About

This project is maintained by Naxam Co.,Ltd.
We specialize in developing mobile applications using Xamarin and native technology stack.

Looking for developers for your project?


Usage

Install Nuget package

Install-Package Naxam.Mapbox.Forms -pre

Add the Mapbox Service to your Manifest

<service android:name="com.mapbox.mapboxsdk.telemetry.TelemetryService" />

Permisisons

Mapbox requires location and internet permissions on the device in order to run.

Android

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />

iOS (info.plist)

<key>NSLocationAlwaysUsageDescription</key>
<string>This app needs to use your location</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs to use your location</string>
<key>MGLMapboxAccessToken</key>
<string>YOUR_MAPBOX_ACCESS_TOKEN</string>

Your XAML

<local:MapView 
    x:Name="map" 
    VerticalOptions="FillAndExpand" 
    MapStyle="{Binding CurrentMapStyle}" 
    ZoomLevel="{Binding ZoomLevel}"
/>

Your code behind

map.DidTapOnMapCommand = new Command<Tuple<Position, Point>>((Tuple<Position, Point> obj) =>
{
    var features = map.GetFeaturesAroundPoint.Invoke(obj.Item2, 6, null);
    var filtered = features.Where((arg) => arg.Attributes != null);
    foreach (IFeature feat in filtered) {
        var str = JsonConvert.SerializeObject(feat);
        System.Diagnostics.Debug.WriteLine(str);
    }

});
map.DidFinishLoadingStyleCommand = new Command<MapStyle>((obj) =>
{
    map.ResetPositionFunc.Execute(null);
    foreach (Layer layer in obj.OriginalLayers)
    {
        System.Diagnostics.Debug.WriteLine(layer.Id);
    }

});
map.ZoomLevel = Device.RuntimePlatform == Device.Android ? 4 : 10;

Detailed documentation is coming soon.

Using Vector Tiles (WMTS)

For example, using a GeoServer WMTS url, and having a workspace named "Ski" and a layer named "planet_osm_line".

After DidFinishLoadingStyle :

var TILESET_URL = "http://localhost:8080/geoserver/gwc/service/wmts?REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&LAYER=Ski:planet_osm_line&STYLE=&TILEMATRIX=EPSG:900913:{z}&TILEMATRIXSET=EPSG:900913&FORMAT=application/vnd.mapbox-vector-tile&TILECOL={x}&TILEROW={y}";

var skiTiles = new TileSet("1.0.0", SOURCE_URL)
{
    MinZoom = 12f,
    MaxZoom = 22f
};

var tileSourceOptions = new TileSourceOptions();
tileSourceOptions.MinimumZoomLevel = 12;
tileSourceOptions.MaximumZoomLevel = 22;

VectorSource vectorSource = new VectorSource("vector-source", skiTiles, tileSourceOptions);

map.Functions.AddSource(vectorSource);

var myLayer = new LineLayer("tile-data", "vector-source")
{
    LineColor = Expression.Color(Color.FromHex("#F13C6E")),
    LineWidth = Expression.Literal(4.0f),
    LineCap = Expression.Literal("round"),
    LineJoin = Expression.Literal("round"),
    SourceLayer = "planet_osm_line"
};
map.Functions.AddLayer(myLayer);

License

Mapbox for Xamarin.Forms is released under the Apache License license. See LICENSE for details.

mapbox-xamarin-forms's People

Contributors

charlenni avatar dependabot[bot] avatar fleuverouge avatar frederikbolding avatar kevm avatar morejump avatar nehpetsetnam avatar nghiaanhit avatar nghiahaminh25101995 avatar saadsaifse avatar tmk907 avatar tuyen-vuduc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mapbox-xamarin-forms's Issues

"Can't resolve reference get_Platform()" when targeting connected iPhone, Forms 4.0.0

Upgraded a working project to the preview of Forms 4.0.0. Now my iOS build breaks when targeting a connected iPhone 6S. Android and iOS simulator targets build and deploy as before. The error:

Can't resolve the reference 'Xamarin.Forms.Internals.IPlatform Xamarin.Forms.Element::get_Platform()', referenced from the method 'System.Void Naxam.Mapbox.Platform.iOS.Extensions.FormsViewContainer::Dispose(System.Boolean)' in 'Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'. CTForms.iOS

According to Microsoft this is a problem with the Naxam.Mapbox component.
xamarin/Xamarin.Forms#4841

Visible Bounding Box (getVisibleRegion)?

Is there a way in MapView or otherwise to get the bounding area(lat,long) of the user's current visible bounding box? I'd imagine the ZoomLevel & Window-extents would be some of what is necessary.

I see in "DownloadMap" there is a reference to CoordinateBounds, but don't see it being set in such a way to get this info.

.Net Standard (Core)

Are there any plans for adopting .Net Standard for this implementation of Mapbox.forms?

View crashes app (black screen)

Hi,

I've been attempting to implement your library in a small Xamarin Forms application that I've been working on. However, as soon as I switch to the page with the MapView on it, the application (and emulator crashes) and I'm left with a black screen. I've only implemented the code in the readme file, but also tested with the sample code.

Any ideas?

Thanks in advance!

Annotation and Feature

I saw, that PointFeature inherits from PointAnnotation.

I assume, that this isn't correct. Annotation and Feature seem to be different things in Mapbox. A Feature consits of Geometries and are drawn on any Layer. Annotations are special Features, that are drawn on a special Layer and are clickable/have an InfoWindow. Is this correct or I'm wrong?

'local' is an undeclared prefix

<local:MapView
x:Name="map"
VerticalOptions="FillAndExpand"
MapStyle="{Binding CurrentMapStyle}"
ZoomLevel="{Binding ZoomLevel}"
/>

Hello
when I used the code above in my Xaml I got this error:

'local' is an undeclared prefix

Not allowed to start service Intent

Hello,

When the application starts on Xamarin Forms (Android) I have this error :

[AndroidRuntime] java.lang.IllegalStateException: Not allowed to start service Intent: app is in background

Have you ever had this error?

Communicate which offline pack an error is for

When a error occurs downloading an offline pack it seems we do not know which offline pack the error is for. If someone is downloading multiple offline packs at once and they get an error they won't be able to relay the error to the correct "actor" downloading the offline pack.

What if we add a reference to the offline pack or at least its Id to the OSSErrorEventArgs error type?

Add POI and Polyline

Hello,
I'm trying to add some points of interest and trying to draw a polyline, but I don't see any function for that. There is no documentation. Have you any idea ?

Draw Area-Polygon

I am looking for how to draw a shaded area once marked at least 3 points
Is it possible? How to?

Thanks.

InfoWindowTemplate implementation throws error using Xamarin Forms 3.5

Hi,

It appears there is a breaking change sometime after Xamarin.Forms 3.1 that causes the InfoWindowTemplate implementation to throw an exception due to mismatched XF versions when you click on an annotation marker on the map.

An update of the Naxam.Mapbox.Forms to the latest XF version resolves the issue, apart from an exception reading the platform in one method in the iOS project which is an unused variable anyway.

Cheers
rj

Offline maps

Any example for download and use offline maps?

Thanks!

New project

Hello, I'm having trouble creating a new project, I downloaded this sample and I managed to run without any problems, but when I create a new project, I do not know how to proceed. What packages do I need?

Android App crash related to Mapbox

Not sure where to report this problem as it seems related to the Android Mapbox bindings. But I searched in that project for MapViewRenderer and RemoveMapEvents and do not get any hits.

I've had this happen twice so far. Each time I was starting to present the Xamarin map view after I had previously showed it.

09-11 13:04:39.072 I/MonoDroid(12573): System.NullReferenceException: Object reference not set to an instance of an object.
09-11 13:04:39.073 I/MonoDroid(12573):   at Naxam.Controls.Mapbox.Platform.Droid.MapViewRenderer.RemoveMapEvents () [0x00000] in <e5e451873e0d4e2aab8595639437d490>:0 
09-11 13:04:39.073 I/MonoDroid(12573):   at Naxam.Controls.Mapbox.Platform.Droid.MapViewRenderer.Dispose (System.Boolean disposing) [0x00008] in <e5e451873e0d4e2aab8595639437d490>:0 

OnMapReady of SupportMapFragment not been invoked

After Downloading the Tiles and loading the map Offline, If we make the app online and then offline after that if you navigate to the Map page , The map doesn't load.

On debugging we found in the above scenario also the GetMapAsync() is being called but we are not getting the OnMapReady() call back. Even the base OnMapReady() is not being invoked

Naxam.Mapbox.Droid version used is 6.4.0.1
Device tested: lenovo k6 Power
OS: android

Steps to Trigger Behavior

  1. Launch the app online
  2. Click on Navigate to the Map page
  3. Click on Offline storage and download to download the tiles.
  4. After the above is completed navigate the back.
  5. Make the app offline and navigate to the map page, You can see the map loads.
  6. Navigate back make the app online and then offline after a few seconds.
  7. Navigate back to the map page.
  8. You will see the map doesn't load

Link to Demonstration

https://drive.google.com/open?id=1cWMxQrCvFwiecmNX0rMPBhBti1_psFoJ

Expected Behavior

From the user perspective the map should load.
From Dev perspective since the below code is getting executed

             fragment = new MapViewFragment();
            activity.SupportFragmentManager.BeginTransaction()
            .Replace(view.Id, fragment)
            .CommitAllowingStateLoss();
            fragment.GetMapAsync(this);

We expect the OnMapReady() callback should be invoked

Actual Behavior

The Map doesn't load.
neither the OnMapReady() call back nor the OnMapReady() override is been called.

Note:- At step 6 we saw the following in the output. Not sure it is relevant.
05-11 12:59:41.198 I/mbgl ( 4437): {DefaultFileSour}[Database]: Unable to make space for entry

When downloading an offline map. Getting an `Unable to resolve host` error

When in the emulator offline maps is working for me with the code below.

When on device (Lenovo Tab 4 7" running Android 7.1), while downloading an offline with map with 40000 total resources I get 327 resources downloaded and then get the following error. This happens each time I try to download the region.

Errors

Error raised on the offline storage service

System.ApplicationException: Offline pack failed to download. Error message: Unable to resolve host "api.mapbox.com": No address associated with hostname occurred

Device Log

Time	Device Name	Type	PID	Tag	Message
09-06 13:37:22.935	LENOVO TB-8504F	Error	7521	mbgl	{GLThread 375}[Style]: Failed to load tile 16/52034/28851=>16 for source composite: Unable to resolve host "api.mapbox.com": No address associated with hostname
09-06 13:37:22.936	LENOVO TB-8504F	Info	7521	mono-stdout	[ERROR] Unable to resolve host "api.mapbox.com": No address associated with hostname REASON_CONNECTION

I thought it might be rate or resource limiting. But I added a credit card to my mapbox account and that didn't fix it.

Code

Below is my calling code (I am wrapping the control in observables)

return Observable.Create<OfflinePack>(async o =>
{
    var disposables = new CompositeDisposable();
    var offlinePack = await _offlineStorageService.DownloadMap(offlineRegion, packInfo);

    _offlineStorageService.RequestPackProgress(offlinePack);

    // For some reason this event only fires when the service is asked for changes.
    var packProgressChanged = Observable.FromEventPattern<OSSEventArgs>(
            h => _offlineStorageService.OfflinePackProgressChanged += h,
            h => _offlineStorageService.OfflinePackProgressChanged -= h)
        .Select(e => e.EventArgs.OfflinePack)
        .Where(olp => olp.Id == offlinePack.Id);

    packProgressChanged.Subscribe(olp =>
    {
        if (olp.State == OfflinePackState.Completed)
        {
            o.OnCompleted();
            return;
        }
        o.OnNext(olp);
    }).AddTo(disposables);

    var packGotError = Observable.FromEventPattern<OSSErrorEventArgs>(
            h => _offlineStorageService.OfflinePackGotError += h,
            h => _offlineStorageService.OfflinePackGotError -= h)
        .Select(e => e.EventArgs.ErrorMessage);

    packGotError
        .Subscribe(errorMessage =>o.OnError(new ApplicationException($"Offline pack failed to download. Error message: {errorMessage}")))
        .AddTo(disposables);

    return disposables;
});

Custom Map Tiles

Hi I was wondering if the SDK supports custom vector Map tiles . If yes then how can I use it? Any information would be of great help.

Blank map in iOS

I'm getting the following errors and a blank map when my iOS MapPage is loaded. Android is working fine.

2018-11-04 00:59:07.097 CTForms.iOS[540:125168] Failed to bind EAGLDrawable: <CAEAGLLayer: 0x28273d3e0> to GL_RENDERBUFFER 1
2018-11-04 00:59:07.097 CTForms.iOS[540:125168] Failed to make complete framebuffer object 8cd6

Mapbox download offline map in iOS

Hi I downloaded this project and run it, and when i run it and click download in iOS, I get an error:

[MESSAGE]Specified cast is not valid.,
[STACK TRACE]: at (wrapper castclass) System.Object.__castclass_with_cache(object,intptr,intptr)
at ObjCRuntime.Runtime.ConstructNSObject[T] (System.IntPtr ptr, System.Type type, ObjCRuntime.Runtime+MissingCtorResolution missingCtorResolution) [0x0003b] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/ObjCRuntime/Runtime.cs:1035
at ObjCRuntime.Runtime.GetNSObject[T] (System.IntPtr ptr) [0x000d1] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/ObjCRuntime/Runtime.cs:1162
at Mapbox.MGLOfflinePack.get_Region () [0x0001d] in <65fb82147ebe47df8ddb210b7bb3ae4b>:0
at Naxam.Controls.Mapbox.Platform.iOS.Extensions.MGLOfflinePackExtensions.ToFormsPack (Mapbox.MGLOfflinePack mbPack) [0x00044] in /Users/aa01/Projects/mapbox-xamarin-forms-master/Naxam.Mapbox.Platform.iOS/Extensions/MGLOfflinePackExtensions.cs:32

i trace where the error occurs and it goes from
here:

    public static OfflinePack ToFormsPack(this MGLOfflinePack mbPack)

    {

        if (mbPack == null) return null;

        var output = new OfflinePack()
        {
            Progress = mbPack.Progress.ToFormsProgress(),

            State = (OfflinePackState)mbPack.State,

            Handle = mbPack.Handle
        };

           var mbRegion = mbPack.Region; //ERROR HERE

            var region = ObjCRuntime.Runtime.GetINativeObject<MGLTilePyramidOfflineRegion>(mbRegion.Handle, false);
            output.Region = region?.ToFormsRegion();

       if (mbPack.Context != null)
        {
            var info = new Dictionary<string, string>();
            NSDictionary userInfo = NSKeyedUnarchiver.UnarchiveObject(mbPack.Context) as NSDictionary;
            foreach (NSObject key in userInfo.Keys)
            {
                info.Add(key.ToString(), userInfo[key].ToString());
            }
            output.Info = info;
        }
        return output;
    }

what can do i do to get the region with out geting the error ?

Thanks for the help!

Import and export shapefile

Hello, how are you?
Can the mapbox control for xamarin read and show a shapefile?
Can you export the shapes made on the map to a shapefile format?

Best regards.

Carlos Palomino.

Setting position at startup (Android)

Coordinates which are set in XAML aren't shown at startup. If you set a new position later, it isn't a problem.

I assume, that the position and zoom should be set again in the OnMapReady event like

            map.CameraPosition = new CameraPosition.Builder()
                .Target(new LatLng(Element.Center.Lat, Element.Center.Long))
                .Zoom(Element.ZoomLevel)
                .Build();

I use the news version on Android simulator.

Problems with Xamarin.Forms implementation

Again, thank you for your great work.

I downloaded the Xamarin.Forms implementation and get the following problems:

  1. In the iOS renderer (MapViewRenderer.cs) I get an error in line 747. I assume, that there is a problem. The part is
 if (Element.MapStyle.CustomLayers is INotifyCollectionChanged notifiyCollection)
 {
   notifiyCollection.CollectionChanged += OnLayersCollectionChanged;
 }

Should the code be

 if (Element.MapStyle.CustomLayers is INotifyCollectionChanged)
 {
   var notifiyCollection = Element.MapStyle.CustomSources as INotifyCollectionChanged;
   notifiyCollection.CollectionChanged += OnLayersCollectionChanged;
 }
  1. When compiling the demo for Android, I get the following error:
The "Xamarin.Build.Download.XamarinBuildAndroidAarProguardConfigs" task could not 
be loaded from the assembly S:\Entwicklung\xf-mapbox-master\packages\Xamarin.Build.Download.0.4.6\build\Xamarin.Build.Download.dll.  
Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are 
available, and that the task contains a public class that implements 
Microsoft.Build.Framework.ITask.
  1. If I want to update to Naxam.Mapbox.Droid 5.1.0.1 as you suggested, than I get an error, because it needs Naxam.Mapzen.Lost.Droid 1.1.1

Perhaps I'm doing something wrong, but I downloaded only the project and tried to start the demo.

Thank you very much for your help.

How to detect that map has been panned

I can detect a tap on the map using DidTapOnMapCommand but there is no equivalent for panning or scrolling or swiping. I've so far been unable to detect gestures using OnPanUpdated or OnSwipeUpdated. The map.PropertyChanged event works sometimes but is unreliable, don't think it was intended for this.

What event will tell me that the map has been panned? I'm testing on iOS and Android hardware.

Draw shapes with LineLayer to represent fields

Hello,

A customer contacted me because he would like to use maps that allow him to display and locate "private areas" (like plots for a farmer) through layers drawn on the map.
The expected result looks like this.

I've seen that MapBox allows to draw shapes on their map, like in this sample.

So I would like to know if it's possible to "import" the areas through shapes that have been created through an admin web app with your plugin (by using LineLayer for example). Or is there another approach that would be better?

Android not building pre96

error: cannot find symbol com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraIdleListener
symbol: class OnCameraIdleListener
location: class MapboxMap testMapBox.Android ...\testMapBox.Android\obj\Debug\android\src\mono\com\mapbox\mapboxsdk\maps\MapboxMap_OnCameraIdleListenerImplementor.java

I try to run the sample you've done but I've got this error. If i try to install mapboxSDK android, I have java conflict.

This bug comes with 6 more, OnCamera...Listener

Nuget install issue

java/lang/String;)Lcom/mapbox/geojson/Geometry;: defining a static interface method requires --min-sdk-version >= 24 (currently 13) for interface methods: com.mapbox.geojson.Geometry.fromJson : (Ljava/lang/String;)Lcom/mapbox/geojson/Geometry; App1.Android

Build warnings when using nuget in .Net standard and core 2.X projects

Warning	NU1701	Package 'Naxam.Mapbox.Forms 1.0.5.2' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.1'. This package may not be fully compatible with your project.	My.Tests	C:\dev\...\My.Tests\My.Tests.csproj	1

Warning	NU1701	Package 'Naxam.Mapbox.Forms 1.0.5.2' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'

My Xamarin Forms project is using .Net standard 2.0 for shared code.

How to set the access token?

Hey

Thanks for sharing this. I'm just testing your code and while there are no errors, i just get a blank screen. But of course I need to set the access token. I know how to do this with the the mapbox api provided by xamarin, but not with this api.

Of course this is a pre-release, so I understand the documentation is not ready yet. But since i've done some work with mapbox before, i thought i might get it running if I just know how to set the access token.

Does your package supports buildings extrusion

Hey,

I would like to know if your library does support 3D buildings extrusion? I tried to use the package of Xamarin but then I saw that they were using (if I am right) yours, which potentially means that you provide more features as well :)

Best,

Max

how to add a marker point on a specific location ?

Hi, I use your package and It's work fine but now I want to add some markers on specific locations.

I just want to be able to add a marker with a specific size and color on a specific location( it's not important if the marker is a squarre or a circle).

but I don't find any advice or example to do it....

thanks for your help :)

Getting "SIGSEGV while executing native code" Error while using the component on a real IOS device.

Hi Folks

First of all great work you did you the xamarin forms mapbox control! It is really handy to use!

Currently we are facing the following exception, while running the control on a real device:

Got a SIGSEGV while executing native code. This usually indi
cates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================
The app has been terminated.

The stacktrace is:

2018-12-16 13:44:30.438 peakR.iOS[29026:9367007] critical: Stacktrace: 2018-12-16 13:44:30.438 peakR.iOS[29026:9367007] critical: at <unknown> <0xffffffff> 2018-12-16 13:44:30.439 peakR.iOS[29026:9367007] critical: at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <0x00007> 2018-12-16 13:44:30.439 peakR.iOS[29026:9367007] critical: at UIKit.UIApplication.Main (string[],intptr,intptr) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.12/src/Xamarin.iOS/UIKit/UIApplication.cs:79 2018-12-16 13:44:30.439 peakR.iOS[29026:9367007] critical: at UIKit.UIApplication.Main (string[],string,string) [0x0002c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.12/src/Xamarin.iOS/UIKit/UIApplication.cs:63 2018-12-16 13:44:30.439 peakR.iOS[29026:9367007] critical: at peakR.iOS.Application.Main (string[]) [0x00001] in P:\_Projects\peakR\peakR\peakR.iOS\Main.cs:17 2018-12-16 13:44:30.440 peakR.iOS[29026:9367007] critical: at (wrapper runtime-invoke) object.runtime_invoke_dynamic (intptr,intptr,intptr,intptr) [0x0001e] in <01f05773bcda4d0b9642de54d8f3cec3#D28A5950-766B-25D1-D528-83C12A6E9914>:0 2018-12-16 13:44:30.440 peakR.iOS[29026:9367007] critical: Native stacktrace: 2018-12-16 13:44:30.453 peakR.iOS[29026:9367007] critical: 0 peakR.iOS 0x00000001072321a8 peakR.iOS + 36757928 2018-12-16 13:44:30.453 peakR.iOS[29026:9367007] critical: 1 peakR.iOS 0x000000010723fe78 mono_pmip + 16100 2018-12-16 13:44:30.453 peakR.iOS[29026:9367007] critical: 2 libsystem_platform.dylib 0x00000001a2500a20 <redacted> + 56 2018-12-16 13:44:30.453 peakR.iOS[29026:9367007] critical: 3 Mapbox 0x0000000108054874 _Z45MBGLCustomGeometrySourceOptionsFromDictionaryP12NSDictionaryIP8NSStringP11objc_objectE + 171232 2018-12-16 13:44:30.453 peakR.iOS[29026:9367007] critical: 4 Mapbox 0x0000000108054a90 _Z45MBGLCustomGeometrySourceOptionsFromDictionaryP12NSDictionaryIP8NSStringP11objc_objectE + 171772 2018-12-16 13:44:30.453 peakR.iOS[29026:9367007] critical: 5 CoreLocation 0x00000001a97ba92c CLClientStopVehicleHeadingUpdates + 77304 2018-12-16 13:44:30.453 peakR.iOS[29026:9367007] critical: 6 CoreLocation 0x00000001a 97ba120 CLClientStopVehicleHeadingUpdates + 75244 2018-12-16 13:44:30.453 peakR.iOS[29026:9367007] critical: 7 CoreLocation 0x00000001a97a3144 CLClientInvalidate + 1348 2018-12-16 13:44:30.453 peakR.iOS[29026:9367007] critical: 8 CoreFoundation 0x00000001a288401c <redacted> + 20 2018-12-16 13:44:30.453 peakR.iOS[29026:9367007] critical: 9 CoreFoundation 0x00000001a288391c <redacted> + 272 2018-12-16 13:44:30.453 peakR.iOS[29026:9367007] critical: 10 CoreFoundation 0x00000001a287ee34 <redacted> + 2376 2018-12-16 13:44:30.453 peakR.iOS[29026:9367007] critical: 11 CoreFoundation 0x00000001a287e1cc CFRunLoopRunSpecific + 436 2018-12-16 13:44:30.453 peakR.iOS[29026:9367007] critical: 12 GraphicsServices 0x00000001a4af5584 GSEventRunModal + 100 2018-12-16 13:44:30.453 peakR.iOS[29026:9367007] critical: 13 UIKitCore 0x00000001cfac1054 UIApplicationMain + 212 2018-12-16 13:44:30.453 peakR.iOS[29026:9367007] critical: 14 peakR.iOS 0x0000000105e22fd8 peakR.iOS + 15724504 2018-12-16 13:44:30.453 peakR.iOS[29026:9367007] critical: 15 peakR.iOS 0x0000000105d93b8c peakR.iOS + 15137676 2018-12-16 13:44:30.453 peakR.iOS[29026:9367007] critical: 16 peakR.iOS 0x0000000105d93b4c peakR.iOS + 15137612 2018-12-16 13:44:30.453 peakR.iOS[29026:9367007] critical: 17 peakR.iOS 0x0000000104f81700 peakR.iOS + 382720 2018-12-16 13:44:30.454 peakR.iOS[29026:9367007] critical: 18 peakR.iOS 0x00000001052889f8 peakR.iOS + 3557880 2018-12-16 13:44:30.454 peakR.iOS[29026:9367007] critical: 19 peakR.iOS 0x0000000107243044 mono_pmip + 28848 2018-12-16 13:44:30.454 peakR.iOS[29026:9367007] critical: 20 peakR.iOS 0x00000001072c70c8 mono_pmip + 569652 2018-12-16 13:44:30.454 peakR.iOS[29026:9367007] critical: 21 peakR.iOS 0x00000001072ccfac mono_pmip + 593944 2018-12-16 13:44:30.454 peakR.iOS[29026:9367007] critical: 22 peakR.iOS 0x000000010722351c peakR.iOS + 36697372 2018-12-16 13:44:30.454 peakR.iOS[29026:9367007] critical: 23 peakR.iOS 0x00000001073bb108 _Z9__isctypeim + 55632 2018-12-16 13:44:30.454 peakR.iOS[29026:9367007] critical: 24 peakR.iOS 0x0000000104f81584 peakR.iOS + 382340 2018-12-16 13:44:30.454 peakR.iOS[29026:9367007] critical: 25 libdyld.dylib 0x00000001a233ebb4 <redacted> + 4 2018-12-16 13:44:30.454 peakR.iOS[29026:9367007] critical:

Any Ideas to solve it?

Thanks in advance.

Best regards

cue

use Mapbox in xamarin froms

Hi;
I develop with xamarin forms (visual studio 2017) for andorid and iOs apps.
I need Get lat and long when user tapped on mapview and
I need set marker on mapview after tapped.
please help me.
thanks

iOS project Reference missing

Hi,

When i try to build/deploy on iOS, the project throws an exception :

error : Can't resolve the reference 'CoreLocation.CLLocationCoordinate2D Mapbox.MGLCoordinateBounds::sw', referenced from the method 'System.Threading.Tasks.Task1<Naxam.Controls.Mapbox.Forms.OfflinePack> Naxam.Controls.Mapbox.Platform.iOS.OfflineStorageService::DownloadMap(Naxam.Controls.Mapbox.Forms.OfflinePackRegion,System.Collections.Generic.Dictionary2<System.String,System.String>,Naxam.Controls.Mapbox.Forms.IOfflineStorageDelegate)' in 'Naxam.Mapbox.iOS, Version=3.6.0.3, Culture=neutral, PublicKeyToken=null'._

My android project works fine.

Best Regards.

Setting page BindingContext=null causes app lock when showing map view a 2nd time

We are seeing the Naxam MapView not work after it initially does work when the page BindingContext is set to null.

  • Show a page .
  • Navigate to a page with a map view.
  • Pop the navigation stack and clean up the page.
    • Call Destroy if it is IDestructable, clean behaviors, reset the BindingContext to null. This last one is what causes this Issue.

This is done by a few MVVM frameworks notably Prism

  • The original page is show. If you try to navigate back to the page with the Naxam MapView. The application locks.

If we do not "clean up the page" the control works fine.

Unfortunately, I do not currently have a reproduction that I can share for this just now.

Potentially Related Issue

If we bind a context to a view hosting a Naxam mapbox view after the view has entered the view hierarchy. Then we are seeing a likely related issue where the map bindings do not work on the second viewing.

If we bind a context to the map view before it enters the view hierarchy everything is fine.

Let me know if you want this second point as a separate issue but they do seem related. Something to do with Binding Context life time.

ShowUserLocation for Android

Hello.
ShowUserLocation property is not used for Android, so user location can`t be shown/tracked automatically.
Is there any possibility to show/track user location for Xamarin Forms Android?

java.lang.RuntimeException: The dimensions from location and bearing drawables should be match

FATAL EXCEPTION: ControllerMessenger
Process: net.trip_hub.istambul, PID: 21708
java.lang.RuntimeException: The dimensions from location and bearing drawables should be match
at com.mapbox.mapboxsdk.maps.widgets.MyLocationView.setForegroundDrawables(MyLocationView.java:193)
at com.mapbox.mapboxsdk.maps.widgets.MyLocationViewSettings.setForegroundDrawable(MyLocationViewSettings.java:189)
at com.mapbox.mapboxsdk.maps.widgets.MyLocationViewSettings.initialise(MyLocationViewSettings.java:98)
at com.mapbox.mapboxsdk.maps.MapboxMap.initialise(MapboxMap.java:99)
at com.mapbox.mapboxsdk.maps.MapView.initialiseMap(MapView.java:220)
at com.mapbox.mapboxsdk.maps.MapView.access$800(MapView.java:70)
at com.mapbox.mapboxsdk.maps.MapView$6$1.run(MapView.java:326)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.support.test.espresso.base.Interrogator.loopAndInterrogate(Interrogator.java:148)
at android.support.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:466)
at android.support.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:420)
at android.support.test.espresso.base.UiControllerImpl.injectMotionEvent(UiControllerImpl.java:234)
at android.support.test.espresso.action.MotionEvents.sendUp(MotionEvents.java:140)
at android.support.test.espresso.action.MotionEvents.sendUp(MotionEvents.java:123)
at android.support.test.espresso.action.Tap.sendSingleTap(Tap.java:170)
at android.support.test.espresso.action.Tap.access$100(Tap.java:31)
at android.support.test.espresso.action.Tap$1.sendTap(Tap.java:46)
at android.support.test.espresso.action.GeneralClickAction.perform(GeneralClickAction.java:136)
at android.support.test.espresso.ViewInteraction$SingleExecutionViewAction.perform(ViewInteraction.java:355)
at android.support.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:242)
at android.support.test.espresso.ViewInteraction.access$100(ViewInteraction.java:62)
at android.support.test.espresso.ViewInteraction$1.call(ViewInteraction.java:149)
at android.support.test.espresso.ViewInteraction$1.call(ViewInteraction.java:146)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7230)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

nuget missing new package

Hi, I can't get new version working because it's missing new package on nuget (Naxam.Mapbox.iOS.4.1.1). I understand you don't want to release a new version yet before testing on official nuget, but do you have other packages sources like myget.org for them?

No implementation found for void com.mapbox.mapboxsdk.net.NativeConnectivityListener.initialize()

Hi Naxam,

I am using Naxam.Mapbox.Droid(6.4.0.1) nugget package for integrating mapbox map in Xamarin forms.While initializing the mapbox sdk I am getting an exception.

{Java.Lang.UnsatisfiedLinkError: No implementation found for void com.mapbox.mapboxsdk.net.NativeConnectivityListener.initialize() (tried Java_com_mapbox_mapboxsdk_net_NativeConnectivityListener_initialize and Java_com_mapbox_mapboxsdk_net_NativeConnectivityListener_initialize__) at Java.Interop.JniEnvironment+StaticMethods.CallStaticObjectMethod (Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00069] in <42dc777b518744fdae9988e94489a4a0>:0 at Java.Interop.JniPeerMembers+JniStaticMethods.InvokeObjectMethod (System.String encodedMember, Java.Interop.JniArgumentValue* parameters) [0x00018] in <42dc777b518744fdae9988e94489a4a0>:0 at Com.Mapbox.Mapboxsdk.Mapbox.GetInstance (Android.Content.Context p0, System.String p1) [0x0004b] in <1c4b424268aa42e29816c89b4cca3283>:0 at Alden.TaskAgent.UI.Droid.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x00020] in E:\ConcertCare\OfflineMapTaskAgent\Alden.TaskAgent\Alden.TaskAgent.UI\TaskAgent.Droid\MainActivity.cs:34 --- End of managed Java.Lang.UnsatisfiedLinkError stack trace --- java.lang.UnsatisfiedLinkError: No implementation found for void com.mapbox.mapboxsdk.net.NativeConnectivityListener.initialize() (tried Java_com_mapbox_mapboxsdk_net_NativeConnectivityListener_initialize and Java_com_mapbox_mapboxsdk_net_NativeConnectivityListener_initialize__) at com.mapbox.mapboxsdk.net.NativeConnectivityListener.initialize(Native Method) at com.mapbox.mapboxsdk.net.NativeConnectivityListener.(NativeConnectivityListener.java:27) at com.mapbox.mapboxsdk.net.ConnectivityReceiver.instance(ConnectivityReceiver.java:39) at com.mapbox.mapboxsdk.Mapbox.getInstance(Mapbox.java:51) at md5de7a84ff76d1b924586c70e2529f1c90.MainActivity.n_onCreate(Native Method) at md5de7a84ff76d1b924586c70e2529f1c90.MainActivity.onCreate(MainActivity.java:31) at android.app.Activity.performCreate(Activity.java:6904) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3266) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415) at android.app.ActivityThread.access$1100(ActivityThread.java:229) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:7331) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) }

Can you help me fixing the issue.

Thanks and Regards,

Sooryan

Clustering PointAnnotation markers with GeoJsonSource

I'm very new to MapBox but was hoping someone could help with this. Please advise if there is a better forum for this question.

I am trying to apply clustering of Markers (PointAnnotations) for a map. I have extended the Naxam.Controls.Mapbox.Platform.Droid.MapViewRenderer from the demo code with the folowing method:

    private const String MARKER_SOURCE = "markers-source";
    private const String MARKER_STYLE_LAYER = "markers-style-layer";

    private void AddMarkers(IList<PointAnnotation> markers)
    {
        var geoJsonOptions = new GeoJsonOptions();
        geoJsonOptions.WithCluster(true);
        geoJsonOptions.WithClusterMaxZoom(14);
        geoJsonOptions.WithClusterRadius(90);

        var markerIcon = context.Resources.GetBitmap("pin");
        map.AddImage("pin", markerIcon);

        IList<Feature> markerFeatures = new List<Feature>();
        for (int i = 0; i < markers.Count; i++)
        {
            foreach (var feature in markers[i].ToFeatureCollection().Features())
            {
                markerFeatures.Add(feature);
            }
        }
        FeatureCollection featureCollection = FeatureCollection.FromFeatures(markerFeatures.ToArray());

        GeoJsonSource source = new GeoJsonSource(MARKER_SOURCE, featureCollection, geoJsonOptions);
        map.AddSource(source);

        /* Style layer: A style layer ties together the source and image and specifies how they are displayed on the map. */
        SymbolLayer markerStyleLayer = new SymbolLayer(MARKER_STYLE_LAYER, MARKER_SOURCE);
        markerStyleLayer.IconImageName = "pin";
        var icon = Context.GetIconFromResource(markerStyleLayer.IconImageName);
        markerStyleLayer.IsVisible = true;
        map.AddLayer(markerStyleLayer.ToNative() );
    }

Debugging shows that the source and layer are added to the MapboxMap but the markers are not rendered.

Multiple Android issues

– With Naxam.Mapbox.Droid 5.1.1.2 my project throws the exception:
Method 'Com.Mapbox.Mapboxsdk.Annotations.BaseMarkerOptions.SetTitle' not found.

When inserting markers on the map:

– Using MapView.DidFinishRenderingCommandthe pin is shown on the map correctly, but it causes the marker callout to not be displayed.

– I created a function in the ViewModel to generate a bunch of markers and return them to be assigned to a bindable property, which is referenced in the map declaration in the xaml file:

Annotations="{Binding MarkersList}".

This is how I call that function:

Device.BeginInvokeOnMainThread(() =>
{
    _ViewModel.MarkersList = _ViewModel.CreateMapMarkers();
});

If I don't use the main thread wrapper, the project throws the following exception:

[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] System.NullReferenceException: Object reference not set to an instance of an object.
[MonoDroid]   at Naxam.Controls.Platform.Droid.MapViewRenderer.RemoveAllAnnotations () [0x00000] in <a65c0c1987e24b2782e4362fe1b815bb>:0 
[MonoDroid]   at Naxam.Controls.Platform.Droid.MapViewRenderer.OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00128] in <a65c0c1987e24b2782e4362fe1b815bb>:0 
[MonoDroid]   at (wrapper delegate-invoke) <Module>:invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs)
[MonoDroid]   at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x0000a] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:137 
[MonoDroid]   at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Element.cs:388 
[MonoDroid]   at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x000f4] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:593 
[MonoDroid]   at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x0015b] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:390 
[MonoDroid]   at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x001f9] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindingExpression.cs:174 
[MonoDroid]   at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) [0x0003e] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindingExpression.cs:56 
[MonoDroid]   at Xamarin.Forms.BindingExpression+BindingExpressionPart.<PropertyChanged>b__47_0 () [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindingExpression.cs:551 
[MonoDroid]   at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <d278c06ad5684d6882c743a94a93ebc2>:0 
[MonoDroid]   at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <d278c06ad5684d6882c743a94a93ebc2>:0 
[MonoDroid]   at (wrapper dynamic-method) System.Object:a1984aa2-f881-43de-8cb4-1a4d8d036f9a (intptr,intptr)

That's all as far as android issues are concerned.

Do you have plans to add support for adding multiple annotations?
Something like https://www.mapbox.com/ios-sdk/examples/annotation-view-image/

Thank you. You did a great job.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.