简体   繁体   中英

MKMap don't display Open Street Map tile overlay

I try display OSM tile as layer above Apple map on MKMapView in Xamarin iOS

private MKTileOverlay _tileOverlay;
...... 
public override void ViewDidLoad ()
{
  .....
  MapDelegate _mapDelegate = new MapDelegate ();
  map.Delegate = _mapDelegate;
  .....

  String urlTemplate = "http://tile.openstreetmap.org/{z}/{x}/{y}.png";
  _tileOverlay = new MKTileOverlay(urlTemplate);
  _tileOverlay.CanReplaceMapContent = true;
  map.AddOverlay(_tileOverlay, MKOverlayLevel.AboveLabels);

  .....
}

and overridden OverlayRenderer in class " MapDelegate : MKMapViewDelegate "

public override MKOverlayRenderer OverlayRenderer (MKMapView mapView, IMKOverlay overlay)
    {
        if (overlay is MKTileOverlay) 
        {
            var tile = (MKTileOverlay)overlay;
            var renderer = new MKTileOverlayRenderer (tile) {
            };

            return renderer;
        }
        return null;
    }

Running the application I see a blank layer without OSM.

What version of iOS are you running ?

Since iOS9 Apple's Application Transport Security (ATS) will, by default, requires the use of HTTPS.

If you want (or need) to use HTTP then you must edit your Info.plist to allow specific (or global) use of HTTP. See Xamarin's documentation for more details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM