Bluemap External Extender is a script that enhances the functionality of BlueMap, allowing for external control and extended features.
- Click the "Code" button and select "Download ZIP".
- Extract the ZIP file to your BlueMap web folder (e.g.,
bluemap/web/js/
). - Rename the extracted folder to
bluemap-external-extender
. - Edit the BlueMap Web configuration file located at
plugins/BlueMap/webapp.conf
. - Add the Bluemap External Extender script to the
scripts
array:
scripts: [
"js/bluemap-external-extender/main.js"
]
- Save the configuration file and restart your server.
Set camera position
Command: updatePosition
Data: x
, y
, z
(number) - camera position in blocks
iframeRef.current.contentWindow.postMessage(
{
type: 'updatePosition',
x: 0,
y: 64,
z: 0
},
'*'
);
Switch view mode
Command: setPerspectiveView
, setFlatView
, setFreeFlight
Options: transition
(number) - transition time in milliseconds
Transition height: heightTransition
(number) - transition height in blocks
iframeRef.current.contentWindow.postMessage(
{
type: 'viewMode',
command: 'setPerspectiveView',
options: { transition: 500, heightTransition: 256 }
},
'*'
);
Follow player
Command: followPlayer
Data: playerId
(string) - player ID
iframeRef.current.contentWindow.postMessage(
{
type: 'followPlayer',
playerId: 'playerId'
},
'*'
);
Update settings
Command: updateSettings
Options: setting
(string) - setting name
hiresDistance
(number) - set hires distancelowresDistance
(number) - set lowres distancesunlightStrength
(number) - set sunlight strengthambientLight
(number) - set ambient light strengthpauseTileLoading
(boolean) - set pause tile loadinginvertMouse
(boolean) - invert mousemouseSensitivity
(number) - set mouse sensitivityshowChunkBorders
(boolean) - set show chunk bordersshowDebug
(boolean) - set show debug informationsuperSampling
(number) - set super sampling valueresetSettings
(boolean) - reset all settings Value:value
(any) - setting value
iframeRef.current.contentWindow.postMessage(
{
type: 'updateSettings',
setting: 'hiresDistance',
value: 1000
},
'*'
);
Teleport to player
Command: teleportToPlayer
Data: playerId
(string) - player ID
iframeRef.current.contentWindow.postMessage(
{
type: 'teleportToPlayer',
playerId: 'playerId'
},
'*'
);
Switch map
Command: switchMap
Data: mapId
(string) - map ID
iframeRef.current.contentWindow.postMessage(
{
type: 'switchMap',
mapId: 'mapId'
},
'*'
);
Reset view
Command: resetView
iframeRef.current.contentWindow.postMessage(
{
type: 'resetView'
},
'*'
);
Animate sunlight strength
Command: animateSunlightStrength
Data: targetValue
(number) - target value
iframeRef.current.contentWindow.postMessage(
{
type: 'animateSunlightStrength',
targetValue: 1
},
'*'
);
Listen to camera position update
Listener: onPosition
Data: x
, y
, z
(number) - camera position in blocks
window.addEventListener('onPosition', (event) =>
{
console.log(event.data);
}
);
Listen to view mode change
Listener: onViewMode
Data: mode
(string) - view mode
window.addEventListener('onViewMode', (event) =>
{
console.log(event.data);
}
);
Listen to follow player status change
Listener: onFollowingPlayerStatus
Data: isFollowing
(boolean) - is following
window.addEventListener('onFollowingPlayerStatus', (event) =>
{
console.log(event.data);
}
);
Listen to map change
Listener: onMapChange
Data: mapId
(string) - map ID
window.addEventListener('onMapChange', (event) =>
{
console.log(event.data);
}
);
Listen to url update
Listener: onUrlChange
Data: url
(string) - url
window.addEventListener('onUrlChange', (event) =>
{
console.log(event.data);
}
);
Listen to sunlight strength update (FIRST TIME ONLY)
Listener: onSunlightStrength
Data: value
(number) - sunlight strength
window.addEventListener('onSunlightStrength', (event) => {
console.log(event.data);
});
Listen to map list update (FIRST TIME ONLY)
Listener: mapListUpdate
Data: mapList
(string) - map list
window.addEventListener('mapListUpdate', (event) => {
console.log(event.data);
});
Listen to all settings update (FIRST TIME ONLY)
Listener: allSettings
Data: settings
(string) - settings
hiresSliderMin
(number) - hires slider minhiresSliderMax
(number) - hires slider maxhiresSliderDefault
(number) - hires slider defaultlowresSliderMin
(number) - lowres slider minlowresSliderMax
(number) - lowres slider maxlowresSliderDefault
(number) - lowres slider defaultresolutionDefault
(number) - resolution defaultversion
(string) - versionmaxZoomDistance
(number) - max zoom distanceminZoomDistance
(number) - min zoom distance
window.addEventListener('allSettings', (event) => {
console.log(event.data);
});
Listen to localStorage update (FIRST TIME ONLY)
Listener: localStorageData
Data: storage
(string) - localStorage data
bluemap-superSampling
(number) - super sampling settingbluemap-mouseSensitivity
(number) - mouse sensitivity settingbluemap-hiresViewDistance
(number) - high resolution view distancebluemap-screenshotClipboard
(boolean) - screenshot to clipboard settingbluemap-pauseTileLoading
(boolean) - pause tile loading settingbluemap-theme
(string | null) - theme settingbluemap-lang
(string) - language settingbluemap-lowresViewDistance
(number) - low resolution view distancebluemap-tileCacheHash
(number) - tile cache hashbluemap-chunkBorders
(boolean) - chunk borders display settingbluemap-resetSettings
(boolean) - reset settings flagbluemap-debug
(boolean) - debug mode settingbluemap-showZoomButtons
(boolean) - show zoom buttons settingbluemap-invertMouse
(boolean) - invert mouse setting
window.addEventListener('localStorageData', (event) => {
console.log(event.data);
});
- Getting player list with
(map url)/maps/(map id)/live/players.json
Get player list:
const mapId = 'map id';
const mapUrl = 'https://example.com';
const fetchPlayers = async () => {
try {
const response = await fetch(`${mapUrl}/maps/${mapId}/live/players.json`);
const data = await response.json();
return data;
} catch (error) {
console.error('Error fetching players:', error);
}
};
Response:
{
"players": [
{
"uuid": "playerId",
"name": "playerName",
"foreign": playerForeign (boolean),
"position": {"x":playerX,"y":playerY,"z":playerZ},
"rotation": {"pitch":playerPitch,"yaw":playerYaw,"roll":playerRoll}
},
{
"uuid": "playerId",
"name": "playerName",
"foreign": playerForeign (boolean),
"position": {"x":playerX,"y":playerY,"z":playerZ},
"rotation": {"pitch":playerPitch,"yaw":playerYaw,"roll":playerRoll}
},
...
]
}
import React, { useRef, useEffect } from 'react';
function BlueMapComponent() {
const iframeRef = useRef(null);
useEffect(() => {
if (iframeRef.current) {
// Example: Set camera position
iframeRef.current.contentWindow.postMessage(
{
type: 'updatePosition',
x: 0,
y: 64,
z: 0
},
''
);
}
}, []);
return (
<iframe
ref={iframeRef}
src="https://example.com"
title="BlueMap"
width="100%"
height="600px"
/>
);
}
export default BlueMapComponent;
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BlueMap Example</title>
</head>
<body>
<iframe id="bluemap-iframe" src="https://example.com" width="100%" height="600px"></iframe>
<script>
const iframeRef = document.getElementById('bluemap-iframe');
// Wait for the iframe to load
iframeRef.onload = function() {
// Example: Set camera position
iframeRef.contentWindow.postMessage(
{
type: 'updatePosition',
x: 0,
y: 64,
z: 0
},
''
);
};
</script>
</body>
These examples show how to get iframe and send messages to iframe.
Todo:
- get marker list
- get player list
- Take screenshot
- send update map
- send update theme
- toggle copy screenshot to clipboard