Sign in to follow this  
Jonneh

Online Map Viewer

Recommended Posts

Well, the steps will vary depending on how you try to do it.. most importantly, where you are putting your files.

The important settings for you to change are in config.json file

You'll need to give it the full path of the serverDirectory (which you get from Citadel and place somewhere on your hard drive)

You'll need to give it the exact name of the "map" or "server"

Set showDeeds: false (I doubt you will be able to reach the RMI port on Citadel to access this feature)

 

a. Create a folder called "mapdumps"

b. extract the above map viewer files into the mapdumps/ folder

c. Download your custom server folder from Citadel and put it in mapdumps/ folder

d. Configure

d. open command prompt and run "java -jar mapviewer.jar"

e. It should generate files and quit. If it doesn't most likely, the directory paths are incorrect, \\ should be used in stead of / (for Windows)

 

Are you able to capture any errors to help with this?

It does require a basic understanding of command line / folder paths

Share this post


Link to post
Share on other sites

Should it work with modified RMI files (webinterface.class) ?

I`m use WUAdmin (it require modified files), and i like to use your very nice map viewer but - i cant see deeds...

it tell everytime - NotBound but WUAdmin working...

Share this post


Link to post
Share on other sites

^ This likely got broken by the most recent patch. WUAdmin is also not working correctly since then because of a critical change in the WU server software.

Share this post


Link to post
Share on other sites

As WUAdmin working and my server version not updated (i dislike autoupdates) i dont think so.

Share this post


Link to post
Share on other sites

It won't work with anything that modifies the existing RMI interface, not much I can do about that :/

 

Edit: Actually you *might* be able to get it working by also replacing the WebInterface class in mapviewer.jar with the modified one as well, as long as it hasn't changed the methods for retrieving deed info.

Edited by Jonneh

Share this post


Link to post
Share on other sites

Hello, I am rather new to Wurm Unlimited, but I am an experienced software developer. While I like this web app, I found a few ways to improve it.

 

Change log:

  • I added 2 variables to keep track of the min and max zoom. I saw in your code that you were awkwardly checking for the min and max zoom. Just use these variables for that.
  • I added gotoCoordinate for 2 reasons: 1) I hope that it may be used in a HUD mini-map mod (though some things may need to change depending on implementation) 2) it is useful for debugging.
  • Now for the biggest addition... Player tracking. If you can pass up at least the x,y coordinates of each player on the server and have it call updatePlayers with JSON serialized data, then you have player tracking.
    • To make this work for real, you will need to add another canvas at the same html level as "<canvas id="map"></canvas>" in "index.html". Give the new canvas a higher z-index than the map canvas. Now you have an overlay! (This trick can also be used for other sorts of tracking such as boats by giving them their own canvas layer.)
    • I'll let you decide where the renderPlayers() call should go in your code.
    • I picked a fuchsia color because it stands out and isn't already being used from what I could tell.
    • I am passing up player names in my example, but it isn't used in the rendering. I put it there to lay the ground work for future features. ;)
    • If you decide to use this feature, make sure to move permanentPlayerColor to config.js as my comment in the code says.

 

Here are my additions to map.js:

 

// playersContainer is the json container of all the players in the server
//{ "players" : [
//	{ "name":"Player1" , "x":500 , "y":500 }
//]}
// example: playersContainer.players[i].name
var playersContainer;

// Zoom values [0.125, 0.25, 0.5, 1, 2, 4, 8, 16]
var minZoom = 0.125;
var maxZoom = 16;

// Move the following line to config.js
var permanentPlayerColor = "rgba(255, 0, 255, 1)";

// (inX, inY) is where you want the view to go to
// zoomIn is a bool asking if you want to be fully zoomed in
function gotoCoordinate(inX, inY, zoomIn) {
	list.setAttribute("style", "display: none;");
	
	if (zoomIn == true)
		zoom = maxZoom;
	
	x = inX * zoom;
	y = inY * zoom;
	
	update();
}

// Takes player data as input then stores/updates it into memory
function updatePlayers(jsonData) {
	playersContainer = JSON.parse(jsonData);
}

// Renders the current players as a 1x1 fuchsia color
function renderPlayers() {
	var tempPlayers = playersContainer;
	
	if (tempPlayers === undefined || tempPlayers.length == 0) {
		console.log("tempPlayers is empty!");
		return;
	}
	
	// playerCanvas would be a canvas overlayed on the map canvas (higher z-index than the map canvas)
	// Clearing it before redrawing makes sure that the old player locations don't stay on the map.
	//playerCanvasContext.clearRect(0, 0, playerCanvas.width, playerCanvas.height);
	
	for(i = 0; i < tempPlayers.players.length; i++) {
		ctx.fillStyle = permanentPlayerColor;
		ctx.fillRect(tempPlayers.players[i].x, tempPlayers.players[i].y, 1, 1);
	}
}

 

Here are the function calls to call the appropriate functions:

// Sample data to seed the list of players
// DELETE this for deployment
var examplePlayerJsonText = '{' +
'"players" : [' +
	'{ "name":"Player1" , "x":500 , "y":500 },' +
	'{ "name":"Player2" , "x":1000 , "y":1000 },' +
	'{ "name":"Player3" , "x":1500 , "y":1500 }' +
']}';

// Function calls
updatePlayers(examplePlayerJsonText);
renderPlayers();
gotoCoordinate(500, 500, true);

 

My goal was to not change any of your existing functions. That way you can plug-and-play with these changes and decide which ones you want to keep.

FYI: the code tags on this forum seem to overly extend the indention of tabs.

  • Like 1

Share this post


Link to post
Share on other sites

Couple quesitons:

 

Where do you add this?

 

Here are the function calls to call the appropriate functions:

// Sample data to seed the list of players
// DELETE this for deployment
var examplePlayerJsonText = '{' +
'"players" : [' +
	'{ "name":"Player1" , "x":500 , "y":500 },' +
	'{ "name":"Player2" , "x":1000 , "y":1000 },' +
	'{ "name":"Player3" , "x":1500 , "y":1500 }' +
']}';

// Function calls
updatePlayers(examplePlayerJsonText);
renderPlayers();
gotoCoordinate(500, 500, true);

 

and second and the code at the top just be added as is to the end of the original map.js file?  

 

Share this post


Link to post
Share on other sites

So I have it going.. but when I go to the map, it's just blue. I tried to run the mapviewer, and it gives me an error at the end in regards to no target sections. Yet, there is a sections folder? 

 

INFO: Rendered 96%
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa
der.java:58)
Caused by: java.nio.file.NoSuchFileException: \var\www\pve\mapviewer\sections
        at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
        at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
        at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
        at sun.nio.fs.WindowsFileSystemProvider.createDirectory(Unknown Source)
        at java.nio.file.Files.createDirectory(Unknown Source)
        at com.wyverngame.mapviewer.MapViewer.save(MapViewer.java:87)
        at com.wyverngame.mapviewer.MapViewer.main(MapViewer.java:278)
        ... 5 more

Edited by Honeysolo

Share this post


Link to post
Share on other sites
On 11/02/2016 at 4:04 AM, Honeysolo said:

So I have it going.. but when I go to the map, it's just blue. I tried to run the mapviewer, and it gives me an error at the end in regards to no target sections. Yet, there is a sections folder? 

 

INFO: Rendered 96%
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa
der.java:58)
Caused by: java.nio.file.NoSuchFileException: \var\www\pve\mapviewer\sections
        at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
        at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
        at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
        at sun.nio.fs.WindowsFileSystemProvider.createDirectory(Unknown Source)
        at java.nio.file.Files.createDirectory(Unknown Source)
        at com.wyverngame.mapviewer.MapViewer.save(MapViewer.java:87)
        at com.wyverngame.mapviewer.MapViewer.main(MapViewer.java:278)
        ... 5 more

 

If the directory definitely exists it's most likely a permissions problem. Try changing the permission on the directory with the command 'chmod a+wr /var/www/pve/mapviewer/sections'.

Edited by Jonneh

Share this post


Link to post
Share on other sites
5 hours ago, Jonneh said:

 

If the directory definitely exists it's most likely a permissions problem. Try changing the permission on the directory with the command 'chmod a+wr /var/www/pve/mapviewer/sections'.

 

Okay.. got it to compile properly now. But the map is still showing up blue, not showing any land? 

Share this post


Link to post
Share on other sites

Just released new version. This update has more accurate deed borders, shows bridges and attempts to reload sections that don't load properly. The setup procedure and config file have changed considerably so you'll need to set everything up again (also paths also no longer need slashes to be escaped in the config file).

Share this post


Link to post
Share on other sites

Jonneh where is all the RMI info go now?  I dont see it in your release.   Looks like you changed the config file name.

Share this post


Link to post
Share on other sites

It grabs data directly from the sqlite files now, without using RMI.

I'd guess it was changed to support non-square deeds - which RMI doesn't report correctly.

 

Edit: Also bridges, don't think RMI supports that at all.

 

Edited by bdew

Share this post


Link to post
Share on other sites
42 minutes ago, bdew said:

It grabs data directly from the sqlite files now, without using RMI.

I'd guess it was changed to support non-square deeds - which RMI doesn't report correctly.

 

Edit: Also bridges, don't think RMI supports that at all.

 

 

 

Ok that fixed that part.. Now im getting this at the last step

 

INFO: Saving 3d map
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa
der.java:58)
Caused by: java.lang.OutOfMemoryError: Java heap space
        at java.awt.image.DataBufferInt.<init>(Unknown Source)
        at java.awt.image.Raster.createPackedRaster(Unknown Source)
        at java.awt.image.DirectColorModel.createCompatibleWritableRaster(Unknow
n Source)
        at java.awt.image.BufferedImage.<init>(Unknown Source)
        at com.wyverngame.mapviewer.Renderer.render(Renderer.java:106)
        at com.wyverngame.mapviewer.Renderer.save(Renderer.java:205)
        at com.wyverngame.mapviewer.MapViewer.main(MapViewer.java:40)
        ... 5 more

 

 

Thoughts? 

Share this post


Link to post
Share on other sites

Nevermind.. this worked:      java -Xmn256M -Xms512m -Xmx1024m  -jar mapviewer.jar

 

Update:

But the map is blank like its not able to read the just the zoom, search box and blue background...  GRRRRRRRRRRRR..

 

Still broken.

Edited by razoreqx

Share this post


Link to post
Share on other sites
44 minutes ago, razoreqx said:

Nevermind.. this worked:      java -Xmn256M -Xms512m -Xmx1024m  -jar mapviewer.jar

 

Update:

But the map is blank like its not able to read the just the zoom, search box and blue background...  GRRRRRRRRRRRR..

 

Still broken.

 

Try removing all the files from the old version (the map.js, main.css, index.html etc) and running it again (it should automatically replace them with the new versions).

Share this post


Link to post
Share on other sites
1 hour ago, Jonneh said:

 

Try removing all the files from the old version (the map.js, main.css, index.html etc) and running it again (it should automatically replace them with the new versions).

 

 

Interesting enough that worked..  But i found with Firefox it doesnt display the map.. Works fine with IE though.   Going to try and purge cache in firefox.     Weird..  I'll test with Chrome as well just to update you on browser support..   nice work Jonneh!

 

Append:

Firefox worked after I cleared the cache.

Chrome worked fine as well.

Edited by razoreqx

Share this post


Link to post
Share on other sites

wow -nice.

 

Small hint: dedicated server with separate user for steamcmd/wurm and www should exceute as root.

Share this post


Link to post
Share on other sites

I've just set up my own server and the map is showing, with the first deed, but 2 more deeds have been created but their names are not showing on the map - I can see the actual settlements but not the deed names, 

 

SHOW_DEEDS = true
SHOW_DEED_BORDERS_IN_3D_MODE = true
SHOW_DEED_BORDERS_IN_FLAT_MODE = true

 

Any ideas?

Share this post


Link to post
Share on other sites
On 13/03/2016 at 8:51 PM, Senitor said:

I've just set up my own server and the map is showing, with the first deed, but 2 more deeds have been created but their names are not showing on the map - I can see the actual settlements but not the deed names, 

 

SHOW_DEEDS = true
SHOW_DEED_BORDERS_IN_3D_MODE = true
SHOW_DEED_BORDERS_IN_FLAT_MODE = true

 

Any ideas?

 

You need to re-run the program every time you want to update the map. You can use some kind of task scheduling software such as cron to do this automatically.

Share this post


Link to post
Share on other sites
On 2/15/2016 at 8:28 AM, razoreqx said:

 

 

Interesting enough that worked..  But i found with Firefox it doesnt display the map.. Works fine with IE though.   Going to try and purge cache in firefox.     Weird..  I'll test with Chrome as well just to update you on browser support..   nice work Jonneh!

 

Append:

Firefox worked after I cleared the cache.

Chrome worked fine as well.

 

This is a cacheing issue.  If you edit the index.html file like it says to on this stackover flow page.  You should never run into a cacheing issue again as long as you remember to change the version number every time you make a change.  This should probably be added to the actual file that generates the files.


 

<script type="text/javascript" src="data.js"></script>
<script type="text/javascript" src="config.js"></script>
<script type="text/javascript" src="map.js"></script>

Should be

 

<script type="text/javascript" src="data.js?version=1.0.0"></script>
<script type="text/javascript" src="config.js?version=1.0.0"></script>
<script type="text/javascript" src="map.js?version=1.0.0"></script>

Then once the document is changed it would change to

<script type="text/javascript" src="data.js?version=1.0.1"></script>
<script type="text/javascript" src="config.js?version=1.0.1"></script>
<script type="text/javascript" src="map.js?version=1.0.1"></script>

This would force any browser to request the file from scratch and continue to cache it until the link changes.

 

Could also generate a random string.  More info on this located http://stackoverflow.com/questions/7413234/how-to-prevent-caching-of-my-javascript-file

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this