고도의 히트 맵을 표시하는 래스터 레이어를 만들려고합니다. 붉은 색이 높은 피크이고 파랑이 바다입니다. OpenLayer 3의 Geolocation (ol.Geolocation)을 활용하려고했지만 정의되지 않은 값을 반환합니다. Geolocation의 주요 용도는 실시간 GPS 위치 확인을위한 것이지만 다른 위치에서도 사용할 수 있어야합니다.OpenLayers 3에 대한 고도 데이터를 얻는 방법?
그렇지 않으면 위도와 경도를 기반으로 고도 데이터를 얻을 수있는 다른 무료 서비스 (Google지도를 사용해야하는 Google Elevation API는 제외)가 있습니까?
app.rasterCounter = 0;
var geolocation = new ol.Geolocation({
projection: map.getView().getProjection()
});
var raster = new ol.source.Raster({
sources: [bing],
operation: function(pixels, data) {
//find the current pixel's location
var y = Math.floor(app.rasterCounter/map.getSize()[0]);
var x = Math.floor(app.rasterCounter % map.getSize()[0]);
//find the pixel's coordinate equivalent
var coords = map.getCoordinateFromPixel([x, y]);
var lonlat = ol.proj.toLonLat(coords);
geolocation.set('position', lonlat);
//if above sea level, then display a heatmap of the long/lati, otherwise display red
var pixel = geolocation.getAltitude() > 0 || geolocation.getAltitude() === undefined ? [0, lonlat[0]+100, lonlat[1]+100, 128] : [255, 0, 0, 128];
app.rasterCounter++;
return pixel;
},
//allow access to the DOM
threads: 0
});
raster.on('afteroperations', function(e) {app.rasterCounter=0;});
참고 : 모든 고도가 정의되지 않았기 때문에 결과에 빨간색이 표시되지 않습니다. :/