所以我在这里使用OpenLayers创建地图:
Option Explicit
Public Sub GetTable()
Dim html As HTMLDocument, hTable As HTMLTable, ws As Worksheet, i As Long
Set ws = ThisWorkbook.Worksheets("Sheet1")
Set html = New HTMLDocument
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", "http://westgateselfstorage.com/index.php?page=estimator", False
.send
html.body.innerHTML = .responseText
End With
Set hTable = html.getElementById("hiderow")
Dim headers(), rows As Object, results(), columns As Object
headers = Array("Size", "Reg price", vbNullString, "Cash price", vbNullString, "Offers", "Reserve")
'grab the rows
Set rows = hTable.getElementsByTagName("tr")
ReDim results(1 To rows.Length, 1 To UBound(headers) + 1)
For i = 1 To rows.Length - 1 'skip headers row
Set columns = rows(i).getElementsByTagName("td")
results(i, 1) = columns(0).innerText
results(i, 2) = columns(3).innerText
results(i, 4) = columns(4).innerText
results(i, 6) = columns(5).innerText
results(i, 7) = "Reserve this unit"
Next
ws.Cells(1, 1).Resize(1, UBound(headers) + 1) = headers
ws.Cells(2, 1).Resize(UBound(results, 1), UBound(results, 2)) = results
End Sub
但是由于某些原因,ZoomSlider无法在地图上渲染。我需要对它进行某种形式的初始化以赋予其大小和位置吗?还是我以错误的方式实例化了它?我尝试使用导入语句var map;
var mapLat = 0;
var mapLng = 0;
var mapDefaultZoom = 14;
var view = new ol.View({
center: ol.proj.fromLonLat([mapLng, mapLat]),
zoom: mapDefaultZoom
});
var oldLayer;
function initMap() {
map = new ol.Map({
target: 'theMap',
layers: [
new ol.layer.Tile({
source: new ol.source.OSM({
url: 'https://a.tile.openstreetmap.org/{z}/{x}/{y}.png'
})
})
],
view: view
});
map.addControl(new ol.control.ZoomSlider());
}
或类似的方法,但是我只有一个错误...
答案 0 :(得分:1)
您需要通过ol.css应用正确的样式,这样才能正确放置“缩放”滑块。
根据上面的代码,在此处查看示例:https://stackblitz.com/edit/ol-zoom-slider
请注意index.html中的样式参考