2016-12-27 34 views
0

我在數據庫中有一個巨大的GIS數據。我在查看地圖之前獲取這些數據並將其轉換爲geoJson文件。我提取所有數據以滿足要求,這需要花費很多時間。有沒有辦法爲用戶正在查看的特定地圖窗口加載數據,並且只使用傳單庫爲同一窗口加載相應的GIS數據?巨大的GIS數據需要使用傳單在地圖上顯示

就我而言,我使用Google地圖在地圖上顯示國家的停車位(GIS數據)。

+1

你可能想提出這個問題到GIS SE:http://gis.stackexchange.com/ – MaryBeth

回答

0

是的,您需要編寫一些代碼才能從服務器獲取特定數據。看看下面的行可以幫助你

//whenever a drag or zoom finish, trigger the function to get new data 
map.on('dragend', getData);//leaflet event 
map.on('zoomend', getData);//leaflet event 

function getData(){ 
    //get the extent of your window 
    var minx = map.getBounds().getEast(); 
    var miny = map.getBounds().getSouth(); 
    var maxx = map.getBounds().getWest(); 
    var maxy = map.getBounds().getNorth(); 

    //trigger an ajax call to get data as per your extent 
    $.ajax({ 
     url: 'url_like_a_php_service', 
     type: "get", 
     dataType: 'json', 
     async: false, 
     //send your extent to service to get specific data, like below 
     data: 'minx=' + minx + '&miny='+miny+ '&maxx='+maxx+ '&maxy='+maxy, 
     beforeSend: function() { 
      //you may write code here like showing a gif on map 
     }, 
     complete: function (response) { 
      //pass data to another function to render on map 
      renderDataonMap(); 
     } 
    }); 
} 
相關問題