Embedded browser in processing

Hi,

I need to put a web browser in a processing sketch. I’m trying with javafx class Webview but with no succes. This is my code for testing.

I need a offline map. I think I can do it with html css js, because I’ve try it with Unfolding maps library, but I only can import mbtiles and my maps are in pbf format and others.

May someone help me please? Another idea?

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.VBox;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

void setup(){
    
    size(800, 480);
    new WebViewer();
}

void draw() {
    //background(0);
}
public class WebViewer extends Application {

    @Override
    public void start(Stage stage) {
        stage.setTitle("HTML");
        stage.setWidth(400);
        stage.setHeight(480);
        Scene scene = new Scene(new Group());

        VBox root = new VBox();     

        final WebView browser = new WebView();
        final WebEngine webEngine = browser.getEngine();

        ScrollPane scrollPane = new ScrollPane();
        scrollPane.setContent(browser);
        webEngine.loadContent("<b>asdf</b>");

        root.getChildren().addAll(scrollPane);
        scene.setRoot(root);

        stage.setScene(scene);
        stage.show();
    }
}

Best regards.

1 Like

It’s probably not what you are looking for, but have you considered just using a .jpg image of a map instead? Just mentioning this because I did this recently for a sketch where I was considering a map but realized that I didn’t need to use the Zoom or any other function, so why not just an image of a map. I just drew the data on top

My simple sketch for reference: https://github.com/tomjuggler/parseCoronavirusSA

1 Like

I need a moving map, but thank you for the option and reply.

I’ve been down this road a few times, although I don’t remember trying to use WebEngine specifically. My personal experience is that it is usually a bad idea trying to put a browser inside a java sketch. If it all possible, it is better to port your sketch to p5.js – then you get a browser for free, because you are running in one (and can also, for example, use iframe or frames).

What kind of map do you need, with what features? Is it up-to-date data from a provider like Google Maps / etc.? Or is it just a bunch of tiled images that you need to drag around a view, and do you need zooming? If the later, than either UnfoldingMaps or just use Tiled – which is designed for games, but works just fine on any 2d collection of image tiles.

1 Like

I need a offline map of real world for navigation (big uav system) from openstreetmap tiles or other provider, using gps position and may be 3d features like synthetic vision system (I don’t know how to do the svs yet).
I need a gui for options like unit system, views,…and change the views
I need to interact with the system, a raspberry pi, to shutdown or restart the system, save some data in the filesystem or update the system, launching a sh file.
I need to interact with sensors, may be serial or CAN bus.

I think that html-css-js is a good idea but I’ve to learn, this is not a problem, may be more time and I’ll need to re-solve some problems I found before.

Thank you very much for your interest Jeremy.

Best regards.

1 Like

If you haven’t already searched there are a couple raspberrypi aircraft and uav interface projects that have been on the forums lately. They are focused on instrumentation, not mapping, but might be of interest.

See for example

I’ve been searching about maps…this is a real big world and it seems to be dispersed.
I think that I can develop my own map server with apache and other componentes and may be I can use unfolding library. There are some tile sets I can use.

Thank you for the example, there are two good projects!

Best regards.

1 Like