Dizzl en medeoplossers,
In bing zou het mogelijk zijn als onderstaande java code kan omgezet worden naar vba.
Jammer genoeg heb ik de competentie niet om java te kunnen converteren naar vba.
function encodePoints(points) {
var latitude = 0;
var longitude = 0;
var result = [];
var l;
for (var point in points ) {
// step 2
var newLatitude = Math.round(points[point][0] * 100000);
var newLongitude = Math.round(points[point][1] * 100000);
// step 3
var dy = newLatitude - latitude;
var dx = newLongitude - longitude;
latitude = newLatitude;
longitude = newLongitude;
// step 4 and 5
dy = (dy << 1) ^ (dy >> 31);
dx = (dx << 1) ^ (dx >> 31);
// step 6
var index = ((dy + dx) * (dy + dx + 1) / 2) + dy;
while (index > 0) {
// step 7
var rem = index & 31;
index = (index - rem) / 32;
// step 8
if (index > 0) rem += 32;
// step 9
result.push("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-"[rem]);
}
}
// step 10
return result.join("");
}
Met onderstaande code vraag ik op basis van het adres, de Latitude en Longitude op. Dit kan met een BingMapsKey.
Function GeocodeAddress(address As String, BingMapsKey As String) As String
Dim oHttpReq As Object
'Set oHttpReq = CreateObject("MSXML2.XMLHTTP60")'failed
Set oHttpReq = CreateObject("MSXML2.XMLHTTP.6.0")
oHttpReq.Open "get", "https://dev.virtualearth.net/REST/v1/Locations?q=" & address & "&o=xml&key=" & BingMapsKey, False
oHttpReq.send
If oHttpReq.ReadyState = 4 Then
oHttpReq.responseXML.SetProperty "SelectionNamespaces", "xmlns:xsi='https://schemas.microsoft.com/search/local/ws/rest/v1'"
GeocodeAddress = oHttpReq.responseXML.selectSingleNode("//xsi:GeocodePoint/xsi:Latitude").Text & "," & oHttpReq.responseXML.selectSingleNode("//xsi:GeocodePoint/xsi:Longitude").Text
End If
End Function
Vriendelijke groeten,
Diezel