2015-10-05 62 views
3

我想通過Open Street Map顯示地圖。只顯示C#代碼中的一小部分地圖,由GMAP和OSM

我在VS2013中有一個C#代碼來顯示通過GMAP和OSM的地圖。

該地圖只能顯示地圖的一小部分。我想我可以看到指定緯度/經度的區域地圖。

爲什麼?

感謝

using System.Windows.Forms; 
using GMap.NET.WindowsForms; 
using GMap.NET; 
using GMap.NET.MapProviders; 
using GMap.NET.WindowsForms.Markers; 

namespace drawMapByGmap 
{ 
    public partial class Form1 : Form 
    { 
    GMapOverlay overlayOne; 
    String contry; 
    public Form1() 
    { 
     InitializeComponent(); 
     this.Load += new EventHandler(this.Form1_Load); 

    } 

    private void Form1_Load(object sender, EventArgs e) 
    { 
     mapexplr_Load(sender, e); 
    } 

    private void mapexplr_Load(object sender, EventArgs e) 
    { 

     //initialisation de notre map 
     gMapControl1.SetPositionByKeywords("Tunisia"); 
     gMapControl1.MapProvider = GMapProviders.OpenStreetMap; 
     gMapControl1.MinZoom = 3; 
     gMapControl1.MaxZoom = 17; 
     gMapControl1.Zoom = 5; 
     gMapControl1.Manager.Mode = AccessMode.ServerAndCache; 
     //ajout des overlay 
     overlayOne = new GMapOverlay("OverlayOne"); 
     //ajout de Markers 
     overlayOne.Markers.Add(new GMap.NET.WindowsForms.Markers.GMarkerGoogle(new PointLatLng(36.657403, 10.327148), GMarkerGoogleType.blue)); 
     ////ajout de overlay à la map 
     gMapControl1.Overlays.Add(overlayOne); 
    } 

    } 
} 
+0

代碼沒有問題,你是否可能從互聯網上斷開連接?您正在使用'AccessMode.ServerAndCache',因此您看到的部分可能來自緩存。 – rdoubleui

回答

0

我想你的代碼並沒有什麼不對的地方,所以你可以嘗試設置管理模式到服務器只

GMapControl1.Manager.Mode = AccessMode.ServerOnly 

並確保您連接到互聯網,這裏是我的測試圖像

enter image description here