在使用 Gmaps 加载 GeoJSON 期间显示加载状态
Show loading status during loading of a GeoJSON using Gmaps
如何使用 loadGeojson
函数 Gmaps 拦截 GeoJSON 的加载?我带了一个MultiLineString的gejson但是需要几秒钟才能出现在屏幕上我需要添加一个加载让用户等待充电
function load(){
google.maps.event.addListener(myLayer, 'addfeature', function (e) {
map.setCenter(e.feature.getGeometry().getAt(0).getAt(0));
});
myLayer.loadGeoJson("/data/myLayer.json");
myLayer.setMap(map);
myLayer.setStyle(function(feature) {
return {
strokeColor: "#B00000",
strokeOpacity:0.8,
strokeWeight: 4
};
});
}
Ivan 你的回答解决了我的问题。谢谢!但是仍然有疑问只有在我创建一个新的地图对象时才有效:
......
var map = new google.maps.Map(document.getElementById('map'), mapOptions);
cicloviasLayer.setMap(map);
我不想创建新地图,而是在现有地图中绘制,在这种情况下如何获得加载 运行?
如this SO answer所述:
使用CSS添加加载giff
图片:
#map_canvas {background: transparent url(images/ajax-loading.gif) no-repeat center center;}
加载地图后会消失,如jsfiddle.
如果你看一下 the API reference,你会发现 loadGeoJson 有一个回调函数作为第三个参数。因此,您可以在调用 loadGeoJson 之前显示微调器,并在调用回调后立即将其隐藏。
如何使用 loadGeojson
函数 Gmaps 拦截 GeoJSON 的加载?我带了一个MultiLineString的gejson但是需要几秒钟才能出现在屏幕上我需要添加一个加载让用户等待充电
function load(){
google.maps.event.addListener(myLayer, 'addfeature', function (e) {
map.setCenter(e.feature.getGeometry().getAt(0).getAt(0));
});
myLayer.loadGeoJson("/data/myLayer.json");
myLayer.setMap(map);
myLayer.setStyle(function(feature) {
return {
strokeColor: "#B00000",
strokeOpacity:0.8,
strokeWeight: 4
};
});
}
Ivan 你的回答解决了我的问题。谢谢!但是仍然有疑问只有在我创建一个新的地图对象时才有效:
......
var map = new google.maps.Map(document.getElementById('map'), mapOptions);
cicloviasLayer.setMap(map);
我不想创建新地图,而是在现有地图中绘制,在这种情况下如何获得加载 运行?
如this SO answer所述:
使用CSS添加加载giff
图片:
#map_canvas {background: transparent url(images/ajax-loading.gif) no-repeat center center;}
加载地图后会消失,如jsfiddle.
如果你看一下 the API reference,你会发现 loadGeoJson 有一个回调函数作为第三个参数。因此,您可以在调用 loadGeoJson 之前显示微调器,并在调用回调后立即将其隐藏。