Change web-view's current page


#1

Rookie here. I’m getting used to NativeScript. So far, so good. However, I have a little issue I want to solve.
It’s quite simple really. I need to update a WebView’s current page to a completely different one.

XML

<Page actionBarHidden="true" loaded="loadpagefunction">
<StackLayout>
<Button text="GET CURRENT LOCATION" tap="enableLocationTap"/>
<Label id="myLabel" text="???, ???"/>
<WebView id="webviewMap" style="height:250px;" src="https://walkchange.com/file/js/maps.html"/>
</StackLayout>

JS

var geolocation = require("nativescript-geolocation");
var locationLabel; 
var webviewCatch;

function loadpagefunction(args) {
console.log("Loaded.");
page = args.object;
locationLabel = page.getViewById("myLabel");
webviewCatch = page.getViewById("webviewMap");
locationLabel.text = "Listo para detectar posición.";
}

function enableLocationTap(args) {
    if (!geolocation.isEnabled()) {
        geolocation.enableLocationRequest();
		console.log("Button Tapped");
    } else {
		var location = geolocation.getCurrentLocation({desiredAccuracy: 3, updateDistance: 10, maximumAge: 20000, timeout: 20000}).
		then(function(loc) {
			if (loc) {
				try {
				console.log("Refresh triggered");
				webviewCatch.src = "https://www.google.com";	
				webviewCatch.reload();
				locationLabel.text = ("Latitude: " + loc.latitude + ", Longitude: " + loc.longitude);
				
				} catch (errWeb){
					
					console.log(errWeb.message);
				
				}
				
			}
		}, function(e){
			console.log("Error: " + e.message);
		});
		
	}
}

exports.enableLocationTap = enableLocationTap;
exports.loadpagefunction = loadpagefunction;

I’ve tried changing the URL and SRC attributes and then refreshing to no avail. I’ve heard of a loadUrl() function for Android, but if I try to execute it, it says that it is not a function.

Please, help. Also, suggestions are welcome. I’m learning to move around NativeScript…