NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

I'm trying to make a Proof of Concept (PoC) regarding Open Street Map (OSM), but my lack of GIS- and Xamarin knowledge (novice) gets me stuck.

What I've done so far is to set up an Azure Virtual Machine (VM) to act as a tile-server by following this guide: https://switch2osm.org/manually-building-a-tile-server-18-04-lts/

I also set up two maps for a web app, connected to my tile server, with OpenLayers.js and Leaflet.js - wich all worked out fine and dandy.

  • What I'm looking for:

  • A guide, tutorial or a hint on how to connect a Xamarin Droid and iOS app (not Xamarin Forms) to my tile-server http://*.*.*.*/${z}/${x}/${y} to get this OSM PoC working across different platforms.

  • Free of charge Xamarin nuget/lib (OsmSharp?) that can connect to my tile-server and render a map.

asked 13 Sep '18, 06:53

Henkolicious's gravatar image

Henkolicious
11112
accept rate: 0%

edited 15 Sep '18, 08:38

aseerel4c26's gravatar image

aseerel4c26 ♦
32.6k18248554


So I figured out how to do this.

  1. Got a zip with .dll's for OsmSharp 2014 here: https://github.com/OsmSharp/ui/releases/tag/v4.2.0.723
  2. Referenced the .dll's in the Xamarin project (Android catalog)
  3. Added this code

styles.xml


style name="Theme" parent="AppTheme" />
style name="Theme.Splash" />
MainActivity.cs
 
    using OsmSharp.Android.UI;
    using OsmSharp.Android.UI.Data.SQLite;
    using OsmSharp.Math.Geo;
    using OsmSharp.UI.Map;
    using OsmSharp.UI.Map.Layers;

    MapView _mapView;
    Layer _mapLayer;

    protected override void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);

        try
        {
            Native.Initialize();

            _mapView = new MapView(this, new MapViewSurface(this))
            {
                MapTilt = 0,
                MapCenter = new GeoCoordinate(your_lat, your_long),
                MapZoom = 16,
                Map = new Map()
            };

            _mapLayer = _mapView.Map.AddLayerTile("http://*.*.*.*/{0}/{1}/{2}.png");
            SetContentView(_mapView);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
        }
    }
 </pre>

However this is and old library and lots of "standard" functionalities are missing. You can add markers etc, but not draw polygons or lines with it, at least not what I can find.

Might help someone. Cheers!

permanent link

answered 13 Sep '18, 15:44

Henkolicious's gravatar image

Henkolicious
11112
accept rate: 0%

Thanks for your sharing your self answer! Is this question fully answered now, or are you still looking for other answers?

(14 Sep '18, 22:16) aseerel4c26 ♦

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×113
×4
×3

question asked: 13 Sep '18, 06:53

question was seen: 5,718 times

last updated: 15 Sep '18, 08:38

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum