1
0
forked from MTSR/mapserver

Merge branch 'master' of github.com:thomasrudin-mt/mapserver

This commit is contained in:
Thomas Rudin 2019-05-04 21:17:53 +02:00
commit b5204b7948
48 changed files with 340 additions and 623 deletions

View File

@ -1,6 +1,5 @@
OUT_DIR=output
MOD_ZIP=$(OUT_DIR)/mapserver-mod.zip
VERSION=git-$(shell git rev-parse HEAD)
all: builder_image $(OUT_DIR) $(MOD_ZIP)
@ -18,20 +17,9 @@ builder_image:
# build the docker image with all dependencies
$(MAKE) -C docker_builder build
$(OUT_DIR):
mkdir $@
$(MOD_ZIP): builder_image $(OUT_DIR)
# lint with luacheck
sudo docker run --rm -it\
-v $(shell pwd)/mapserver_mod/mapserver:/app\
-w /app\
mapserver-builder\
luacheck .
# zip mod
zip -r $(OUT_DIR)/mapserver-mod.zip mapserver_mod
clean:
rm -rf $(OUT_DIR)
$(MAKE) -C server clean

View File

@ -1,6 +1,14 @@
# Changelog
## 2.1.0
* Added search bar
* Shop info with stock
* Colored POI's
* Icons for POI's
* Exported mapserver mod to own repository: https://github.com/thomasrudin/mapserver_mod
## 2.0.1
* Added *configversion* to `mapserver.json`
* Added *defaultoverlays* to `mapserver.json`

12
doc/internal/textures.md Normal file
View File

@ -0,0 +1,12 @@
# convert
```sh
sudo apt install imagemagick
convert markers-soft.png -crop 36x46+0+0 -resize 28% mapserver_poi_red.png
convert markers-soft.png -crop 36x46+36+0 -resize 28% mapserver_poi_orange.png
convert markers-soft.png -crop 36x46+72+0 -resize 28% mapserver_poi_green.png
convert markers-soft.png -crop 36x46+108+0 -resize 28% mapserver_poi_blue.png
convert markers-soft.png -crop 36x46+144+0 -resize 28% mapserver_poi_violet.png
convert markers-soft.png -crop 36x46+180+0 -resize 28% mapserver_poi_brown.png
```

View File

@ -54,3 +54,7 @@
* minecart_logo.png
** License: CC0
** Source [minecart](https://github.com/joe7575/minecart)
* mapserver_gold_block.png
** License: CC BY-SA 3.0
** Source [minetest_game](https://github.com/minetest/minetest_game)

View File

@ -17,6 +17,9 @@ See: https://github.com/minetest-mods/digilines
## POI
<img src="../pics/poi.png">
<img src="../pics/poi_icons.png">
All supported icons: https://fontawesome.com/icons?d=gallery&s=regular,solid&m=free
## Protector
@ -27,5 +30,9 @@ See: https://github.com/Sokomine/travelnet
<img src="../pics/travelnet.png">
## Trains from advtrains
<img src="../pics/trains.png">
## More
And various more, see: [setup.go](../server/mapobject/setup.go)

View File

@ -1,6 +1,8 @@
# Mapserver mod
* Repository: https://github.com/thomasrudin/mapserver_mod
If the `mapserver-mod` is installed and configured
you get more realtime-data from within your minetest-world:

12
doc/search.md Normal file
View File

@ -0,0 +1,12 @@
# Search bar
Searchable objects:
* Shops (with stock info)
* POI's
* Trainstations
* Travelnets
Example:
<img src="../pics/search.png">

View File

@ -1,23 +0,0 @@
unused_args = false
allow_defined_top = true
globals = {
"mapserver"
}
read_globals = {
-- Stdlib
string = {fields = {"split"}},
table = {fields = {"copy", "getn"}},
-- Minetest
"minetest",
"vector", "ItemStack",
"dump",
-- Deps
"unified_inventory", "default", "advtrains",
-- optional mods
"xban"
}

View File

@ -1,81 +0,0 @@
local last_index = 0
local last_name = ""
local update_formspec = function(meta)
local name = meta:get_string("name")
local index = meta:get_string("index")
local color = meta:get_string("color") or "rgb(10,10,200)"
meta:set_string("infotext", "Border: Name=" .. name .. ", Index=" .. index)
meta:set_string("formspec", "size[8,4;]" ..
-- col 1
"field[0,1;4,1;name;Name;" .. name .. "]" ..
"button_exit[4,1;4,1;save;Save]" ..
-- col 2
"field[4,2.5;4,1;index;Index;" .. index .. "]" ..
-- col 3
"field[4,3.5;4,1;color;Color;" .. color .. "]" ..
"")
end
minetest.register_node("mapserver:border", {
description = "Mapserver Border",
tiles = {
"mapserver_border.png"
},
groups = {cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),
can_dig = mapserver.can_dig,
after_place_node = mapserver.after_place_node,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
last_index = last_index + 5
meta:set_string("color", "rgb(10,10,200)")
meta:set_string("name", last_name)
meta:set_int("index", last_index)
update_formspec(meta)
end,
on_receive_fields = function(pos, formname, fields, sender)
if not mapserver.can_interact(pos, sender) then
return
end
local meta = minetest.get_meta(pos)
if fields.save then
last_name = fields.name
meta:set_string("name", fields.name)
meta:set_string("color", fields.color)
local index = tonumber(fields.index)
if index ~= nil then
last_index = index
meta:set_int("index", index)
end
end
update_formspec(meta)
end
})
if mapserver.enable_crafting then
minetest.register_craft({
output = 'mapserver:border',
recipe = {
{"", "default:steel_ingot", ""},
{"default:paper", "default:goldblock", "default:paper"},
{"", "default:glass", ""}
}
})
end

View File

@ -1,31 +0,0 @@
mapserver.bridge.add_advtrains = function(data)
data.trains = {}
for _, train in pairs(advtrains.trains) do
local t = {
text_outside = train.text_outside,
text_inside = train.text_inside,
line = train.line,
pos = train.last_pos,
velocity = train.velocity,
off_track = train.off_track,
id = train.id,
wagons = {}
}
for _, part in pairs(train.trainparts) do
local wagon = advtrains.wagons[part]
if wagon ~= nil then
table.insert(t.wagons, {
id = wagon.id,
type = wagon.type,
pos_in_train = wagon.pos_in_train,
})
end
end
table.insert(data.trains, t)
end
end

View File

@ -1,24 +0,0 @@
local function explode(sep, input)
local t={}
local i=0
for k in string.gmatch(input,"([^"..sep.."]+)") do
t[i]=k
i=i+1
end
return t
end
local function get_max_lag()
local arrayoutput = explode(", ",minetest.get_server_status())
arrayoutput = explode("=",arrayoutput[4])
return arrayoutput[1]
end
mapserver.bridge.add_defaults = function(data)
data.time = minetest.get_timeofday() * 24000
data.uptime = minetest.get_server_uptime()
data.max_lag = tonumber(get_max_lag())
end

View File

@ -1,69 +0,0 @@
local MP = minetest.get_modpath("mapserver")
dofile(MP .. "/bridge/defaults.lua")
dofile(MP .. "/bridge/players.lua")
dofile(MP .. "/bridge/advtrains.lua")
dofile(MP .. "/bridge/minecart.lua")
-- mapserver http bridge
local has_advtrains = minetest.get_modpath("advtrains")
local has_minecart = minetest.get_modpath("minecart")
local http, url, key
function send_stats()
local t0 = minetest.get_us_time()
-- data to send to mapserver
local data = {}
mapserver.bridge.add_players(data)
mapserver.bridge.add_defaults(data)
if has_minecart then
-- send minecarts positions if mod is installed
mapserver.bridge.add_minecart(data)
end
if has_advtrains then
-- send trains if 'advtrains' mod installed
mapserver.bridge.add_advtrains(data)
end
local json = minetest.write_json(data)
--print(json)--XXX
local t1 = minetest.get_us_time()
local process_time = t1 - t0
if process_time > 10000 then
minetest.log("warning", "[mapserver-bridge] processing took " .. process_time .. " us")
end
http.fetch({
url = url .. "/api/minetest",
extra_headers = { "Content-Type: application/json", "Authorization: " .. key },
timeout = 1,
post_data = json
}, function(res)
local t2 = minetest.get_us_time()
local post_time = t2 - t1
if post_time > 1000000 then -- warn if over a second
minetest.log("warning", "[mapserver-bridge] post took " .. post_time .. " us")
end
-- TODO: error-handling
minetest.after(2, send_stats)
end)
end
function mapserver.bridge_init(_http, _url, _key)
http = _http
url = _url
key = _key
minetest.after(2, send_stats)
end

View File

@ -1,4 +0,0 @@
mapserver.bridge.add_minecart = function(data)
data.minecarts = minecart.get_cart_list()
end

View File

@ -1,23 +0,0 @@
mapserver.bridge.add_players = function(data)
data.players = {}
for _, player in ipairs(minetest.get_connected_players()) do
local is_hidden = minetest.check_player_privs(player:get_player_name(), {mapserver_hide_player = true})
local info = {
name = player:get_player_name(),
pos = player:get_pos(),
hp = player:get_hp(),
breath = player:get_breath(),
velocity = player:get_player_velocity()
}
if not is_hidden then
table.insert(data.players, info)
end
end
end

View File

@ -1,28 +0,0 @@
mapserver.can_dig = function(pos, player)
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
return player and player:get_player_name() == owner
end
mapserver.after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name() or "")
end
mapserver.can_interact = function(pos, player)
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
local playername = player:get_player_name()
if playername == owner then
return true
end
if minetest.check_player_privs(playername, {protection_bypass = true}) then
return true
end
return false
end

View File

@ -1,3 +0,0 @@
default
advtrains?
minecart?

View File

@ -1,78 +0,0 @@
local update_formspec = function(meta)
local text = meta:get_string("text")
local size = meta:get_string("size")
local direction = meta:get_string("direction")
local color = meta:get_string("color") or "rgb(0,0,0)"
meta:set_string("infotext", "Label, Text:" .. text .. ", Size:" .. size .. ", Direction:" .. direction)
meta:set_string("formspec", "size[8,6;]" ..
-- col 1
"field[0,1;4,1;text;Text;" .. text .. "]" ..
"button_exit[4,1;4,1;save;Save]" ..
-- col 2
"field[0,2.5;4,1;size;Size (1-10);" .. size .. "]" ..
-- col 3
"field[0,3.5;8,1;direction;Direction (0-360);" .. direction .. "]" ..
-- col 4
"field[0,4.5;8,1;color;Color;" .. color .. "]" ..
"")
end
minetest.register_node("mapserver:label", {
description = "Mapserver Label",
tiles = {
"mapserver_label.png"
},
groups = {cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),
can_dig = mapserver.can_dig,
after_place_node = mapserver.after_place_node,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("text", "")
meta:set_string("direction", "0")
meta:set_string("size", "20")
meta:set_string("color", "rgb(0,0,0)")
update_formspec(meta)
end,
on_receive_fields = function(pos, formname, fields, sender)
if not mapserver.can_interact(pos, sender) then
return
end
local meta = minetest.get_meta(pos)
if fields.save then
meta:set_string("color", fields.color)
meta:set_string("text", fields.text)
meta:set_string("direction", fields.direction)
meta:set_string("size", fields.size)
end
update_formspec(meta)
end
})
if mapserver.enable_crafting then
minetest.register_craft({
output = 'mapserver:label',
recipe = {
{"", "default:paper", ""},
{"default:paper", "default:goldblock", "default:paper"},
{"", "default:glass", ""}
}
})
end

View File

@ -1,20 +0,0 @@
minetest.register_lbm({
label = "Tileserver->Mapserver poi upgrade",
name = "mapserver:poi",
nodenames = {"tileserver:poi"},
run_at_every_load = true,
action = function(pos, node)
minetest.swap_node(pos, { name="mapserver:poi" })
end
})
minetest.register_lbm({
label = "Tileserver->Mapserver train upgrade",
name = "mapserver:train",
nodenames = {"tileserver:train"},
run_at_every_load = true,
action = function(pos, node)
minetest.swap_node(pos, { name="mapserver:train" })
end
})

View File

@ -1,72 +0,0 @@
local update_formspec = function(meta)
local name = meta:get_string("name")
local category = meta:get_string("category")
local url = meta:get_string("url") or ""
meta:set_string("infotext", "POI: " .. name .. ", " .. category)
meta:set_string("formspec", "size[8,5;]" ..
-- col 1
"field[0,1;4,1;name;Name;" .. name .. "]" ..
"button_exit[4,1;4,1;save;Save]" ..
-- col 2
"field[0,2.5;4,1;category;Category;" .. category .. "]" ..
-- col 3
"field[0,3.5;8,1;url;URL;" .. url .. "]" ..
"")
end
minetest.register_node("mapserver:poi", {
description = "Mapserver POI",
tiles = {
"mapserver_poi.png"
},
groups = {cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),
can_dig = mapserver.can_dig,
after_place_node = mapserver.after_place_node,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("name", "<unconfigured>")
meta:set_string("category", "main")
meta:set_string("url", "")
update_formspec(meta)
end,
on_receive_fields = function(pos, formname, fields, sender)
if not mapserver.can_interact(pos, sender) then
return
end
local meta = minetest.get_meta(pos)
if fields.save then
meta:set_string("name", fields.name)
meta:set_string("url", fields.url)
meta:set_string("category", fields.category)
end
update_formspec(meta)
end
})
if mapserver.enable_crafting then
minetest.register_craft({
output = 'mapserver:poi',
recipe = {
{"", "dye:blue", ""},
{"default:paper", "default:goldblock", "default:paper"},
{"", "default:glass", ""}
}
})
end

View File

@ -1,5 +0,0 @@
minetest.register_privilege("mapserver_hide_player", {
description = "Player is hidden from the map",
give_to_singleplayer = false
})

View File

@ -1,12 +0,0 @@
# mapserver mod
## active mode configuration
minetest.conf
```
secure.http_mods = mapserver
mapserver.url = http://127.0.0.1:8080
mapserver.key = myserverkey
```

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 313 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 279 B

View File

@ -1,86 +0,0 @@
local last_index = 0
local last_line = ""
local update_formspec = function(meta)
local line = meta:get_string("line")
local station = meta:get_string("station")
local index = meta:get_string("index")
local color = meta:get_string("color") or ""
meta:set_string("infotext", "Train: Line=" .. line .. ", Station=" .. station)
meta:set_string("formspec", "size[8,4;]" ..
-- col 1
"field[0,1;4,1;line;Line;" .. line .. "]" ..
"button_exit[4,1;4,1;save;Save]" ..
-- col 2
"field[0,2.5;4,1;station;Station;" .. station .. "]" ..
"field[4,2.5;4,1;index;Index;" .. index .. "]" ..
-- col 3
"field[0,3.5;4,1;color;Color;" .. color .. "]" ..
""
)
end
minetest.register_node("mapserver:train", {
description = "Mapserver Train",
tiles = {
"mapserver_train.png"
},
groups = {cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),
can_dig = mapserver.can_dig,
after_place_node = mapserver.after_place_node,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
last_index = last_index + 5
meta:set_string("station", "")
meta:set_string("line", last_line)
meta:set_int("index", last_index)
meta:set_string("color", "rgb(10,10,200)")
update_formspec(meta)
end,
on_receive_fields = function(pos, formname, fields, sender)
if not mapserver.can_interact(pos, sender) then
return
end
local meta = minetest.get_meta(pos)
if fields.save then
last_line = fields.line
meta:set_string("color", fields.color)
meta:set_string("line", fields.line)
meta:set_string("station", fields.station)
local index = tonumber(fields.index)
if index ~= nil then
last_index = index
meta:set_int("index", index)
end
end
update_formspec(meta)
end
})
if mapserver.enable_crafting then
minetest.register_craft({
output = 'mapserver:train',
recipe = {
{"", "default:steel_ingot", ""},
{"default:paper", "default:goldblock", "default:paper"},
{"", "default:glass", ""}
}
})
end

BIN
pics/poi_icons.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

BIN
pics/pois_ingame.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 376 KiB

BIN
pics/search.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

View File

@ -14,6 +14,7 @@ Realtime mapserver for [Minetest](https://minetest.net)
* [Installation](doc/install.md)
* [Mapserver mod](doc/mod.md)
* [Parameters](doc/params.md)
* [Search](doc/search.md)
* [Configuration](doc/config.md)
* [Contribution](doc/contrib.md)
* [Development](doc/dev.md)

View File

@ -1,33 +0,0 @@
#!/bin/sh
VERSION=$1
test -z "$VERSION" &&{
echo "Usage: $0 <version>"
exit 1
}
make clean all
git tag $VERSION
export GITHUB_TOKEN=`cat .releasetoken`
gothub="go run github.com/itchio/gothub"
gothub_release="$gothub release --user thomasrudin-mt --repo mapserver"
gothub_upload="$gothub upload --user thomasrudin-mt --repo mapserver"
$gothub_release --tag $VERSION --name "Version $VERSION"
FILES="mapserver-linux-arm mapserver-linux-x86 mapserver-linux-x86_64 mapserver-mod.zip mapserver-windows-x86-64.exe mapserver-windows-x86.exe"
for file in $FILES
do
$gothub_upload --tag $VERSION --name "$file" --file output/$file
done
git push --tags

View File

@ -14,6 +14,7 @@ type GenericPos struct {
type Area struct {
Owner string `json:"owner"`
Name string `json:"name"`
Parent int `json:"parent"`
Pos1 *GenericPos `json:"pos1"`
Pos2 *GenericPos `json:"pos2"`
}
@ -41,6 +42,9 @@ func Parse(data []byte) ([]*Area, error) {
a := Area{}
a.Name = entry["name"].(string)
a.Owner = entry["owner"].(string)
if entry["parent"] != nil {
a.Parent = entry["parent"].(int)
}
p1 := GenericPos{}
pos1 := entry["pos1"].(map[string]interface{})

View File

@ -5,7 +5,9 @@ import (
"mapserver/mapobjectdb"
)
type PoiBlock struct{}
type PoiBlock struct {
Color string
}
func (this *PoiBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject {
md := block.Metadata.GetMetadata(x, y, z)
@ -15,6 +17,8 @@ func (this *PoiBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *
o.Attributes["category"] = md["category"]
o.Attributes["url"] = md["url"]
o.Attributes["owner"] = md["owner"]
o.Attributes["icon"] = md["icon"]
o.Attributes["color"] = this.Color
return o
}

View File

@ -13,7 +13,12 @@ func Setup(ctx *app.App) {
//mapserver stuff
if ctx.Config.MapObjects.MapserverPOI {
l.AddMapObject("mapserver:poi", &PoiBlock{})
l.AddMapObject("mapserver:poi", &PoiBlock{Color: "blue"})
l.AddMapObject("mapserver:poi_blue", &PoiBlock{Color: "blue"})
l.AddMapObject("mapserver:poi_green", &PoiBlock{Color: "green"})
l.AddMapObject("mapserver:poi_orange", &PoiBlock{Color: "orange"})
l.AddMapObject("mapserver:poi_red", &PoiBlock{Color: "red"})
l.AddMapObject("mapserver:poi_purple", &PoiBlock{Color: "purple"})
}
if ctx.Config.MapObjects.MapserverTrainline {

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 535 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB

View File

@ -0,0 +1,128 @@
/*
Author: L. Voogdt
License: MIT
Version: 1.0
*/
/* Marker setup */
.awesome-marker {
background: url('images/markers-soft.png') no-repeat 0 0;
width: 35px;
height: 46px;
position:absolute;
left:0;
top:0;
display: block;
text-align: center;
}
.awesome-marker-shadow {
background: url('images/markers-shadow.png') no-repeat 0 0;
width: 36px;
height: 16px;
}
/* Retina displays */
@media (min--moz-device-pixel-ratio: 1.5),(-o-min-device-pixel-ratio: 3/2),
(-webkit-min-device-pixel-ratio: 1.5),(min-device-pixel-ratio: 1.5),(min-resolution: 1.5dppx) {
.awesome-marker {
background-image: url('images/markers-soft@2x.png');
background-size: 720px 92px;
}
.awesome-marker-shadow {
background-image: url('images/markers-shadow@2x.png');
background-size: 35px 16px;
}
}
.awesome-marker i {
color: #333;
margin-top: 10px;
display: inline-block;
font-size: 14px;
}
.awesome-marker .icon-white {
color: #fff;
}
/* Colors */
.awesome-marker-icon-red {
background-position: 0 0;
}
.awesome-marker-icon-darkred {
background-position: -180px 0;
}
.awesome-marker-icon-lightred {
background-position: -360px 0;
}
.awesome-marker-icon-orange {
background-position: -36px 0;
}
.awesome-marker-icon-beige {
background-position: -396px 0;
}
.awesome-marker-icon-green {
background-position: -72px 0;
}
.awesome-marker-icon-darkgreen {
background-position: -252px 0;
}
.awesome-marker-icon-lightgreen {
background-position: -432px 0;
}
.awesome-marker-icon-blue {
background-position: -108px 0;
}
.awesome-marker-icon-darkblue {
background-position: -216px 0;
}
.awesome-marker-icon-lightblue {
background-position: -468px 0;
}
.awesome-marker-icon-purple {
background-position: -144px 0;
}
.awesome-marker-icon-darkpurple {
background-position: -288px 0;
}
.awesome-marker-icon-pink {
background-position: -504px 0;
}
.awesome-marker-icon-cadetblue {
background-position: -324px 0;
}
.awesome-marker-icon-white {
background-position: -574px 0;
}
.awesome-marker-icon-gray {
background-position: -648px 0;
}
.awesome-marker-icon-lightgray {
background-position: -612px 0;
}
.awesome-marker-icon-black {
background-position: -682px 0;
}
.awesome-marker-square {
background-position-y: -46px;
}

View File

@ -0,0 +1,125 @@
/*
Leaflet.AwesomeMarkers, a plugin that adds colorful iconic markers for Leaflet, based on the Font Awesome icons
(c) 2012-2013, Lennard Voogdt
http://leafletjs.com
https://github.com/lvoogdt
*/
/*global L*/
(function (window, document, undefined) {
"use strict";
/*
* Leaflet.AwesomeMarkers assumes that you have already included the Leaflet library.
*/
L.AwesomeMarkers = {};
L.AwesomeMarkers.version = '2.0.1';
L.AwesomeMarkers.Icon = L.Icon.extend({
options: {
iconSize: [35, 45],
iconAnchor: [17, 42],
popupAnchor: [1, -32],
shadowAnchor: [10, 12],
shadowSize: [36, 16],
className: 'awesome-marker',
prefix: 'glyphicon',
spinClass: 'fa-spin',
extraClasses: '',
icon: 'home',
markerColor: 'blue',
iconColor: 'white'
},
initialize: function (options) {
options = L.Util.setOptions(this, options);
},
createIcon: function () {
var div = document.createElement('div'),
options = this.options;
if (options.icon) {
div.innerHTML = this._createInner();
}
if (options.bgPos) {
div.style.backgroundPosition =
(-options.bgPos.x) + 'px ' + (-options.bgPos.y) + 'px';
}
this._setIconStyles(div, 'icon-' + options.markerColor);
return div;
},
_createInner: function() {
var iconClass, iconSpinClass = "", iconColorClass = "", iconColorStyle = "", options = this.options;
if(options.icon.slice(0,options.prefix.length+1) === options.prefix + "-") {
iconClass = options.icon;
} else {
iconClass = options.prefix + "-" + options.icon;
}
if(options.spin && typeof options.spinClass === "string") {
iconSpinClass = options.spinClass;
}
if(options.iconColor) {
if(options.iconColor === 'white' || options.iconColor === 'black') {
iconColorClass = "icon-" + options.iconColor;
} else {
iconColorStyle = "style='color: " + options.iconColor + "' ";
}
}
return "<i " + iconColorStyle + "class='" + options.extraClasses + " " + options.prefix + " " + iconClass + " " + iconSpinClass + " " + iconColorClass + "'></i>";
},
_setIconStyles: function (img, name) {
var options = this.options,
size = L.point(options[name === 'shadow' ? 'shadowSize' : 'iconSize']),
anchor;
if (name === 'shadow') {
anchor = L.point(options.shadowAnchor || options.iconAnchor);
} else {
anchor = L.point(options.iconAnchor);
}
if (!anchor && size) {
anchor = size.divideBy(2, true);
}
img.className = 'awesome-marker-' + name + ' ' + options.className;
if (anchor) {
img.style.marginLeft = (-anchor.x) + 'px';
img.style.marginTop = (-anchor.y) + 'px';
}
if (size) {
img.style.width = size.x + 'px';
img.style.height = size.y + 'px';
}
},
createShadow: function () {
var div = document.createElement('div');
this._setIconStyles(div, 'shadow');
return div;
}
});
L.AwesomeMarkers.icon = function (options) {
return new L.AwesomeMarkers.Icon(options);
};
}(this, document));

View File

@ -1,20 +1,17 @@
/* exported PoiOverlay */
/* globals AbstractIconOverlay: true */
var PoiIcon = L.icon({
iconUrl: 'css/images/marker-icon.png',
shadowUrl: 'css/images/marker-shadow.png',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
tooltipAnchor: [16, -28],
shadowSize: [41, 41]
});
var PoiOverlay = AbstractIconOverlay.extend({
initialize: function(wsChannel, layerMgr) {
AbstractIconOverlay.prototype.initialize.call(this, wsChannel, layerMgr, "poi", PoiIcon);
AbstractIconOverlay.prototype.initialize.call(this, wsChannel, layerMgr, "poi");
},
getIcon: function(obj){
return L.AwesomeMarkers.icon({
icon: obj.attributes.icon || "home",
prefix: "fa",
markerColor: obj.attributes.color || "blue"
});
},
getMaxDisplayedZoom: function(){

View File

@ -6,6 +6,10 @@ var ProtectorOverlay = AbstractGeoJsonOverlay.extend({
AbstractGeoJsonOverlay.prototype.initialize.call(this, wsChannel, layerMgr, "protector");
},
getMaxDisplayedZoom: function(){
return 11;
},
createFeature: function(protector){
return {
"type":"Feature",

View File

@ -40,7 +40,13 @@ var SearchResult = {
if (obj.type == "poi"){
description = m("span", obj.attributes.name);
type = m("img", { src: "css/images/marker-icon.png" });
var color = obj.attributes.color || "blue";
var icon = obj.attributes.icon || "home";
type = m("div", { style: "position: relative", class: "awesome-marker awesome-marker-icon-" + color }, [
m("i", { class: "fa fa-" + icon })
]);
}
if (obj.type == "shop") {

View File

@ -1,6 +1,7 @@
{
"scripts": [
"/js/lib/leaflet.js",
"/js/lib/leaflet.awesome-markers.js",
"/js/lib/mithril.min.js",
"/js/lib/color-hash.js",
"/js/util/debounce.js",
@ -47,6 +48,7 @@
"/css/fontawesome.min.css",
"/css/bootstrap.min.css",
"/css/leaflet.css",
"/css/leaflet.awesome-markers.css",
"/css/custom.css"
]
}