【问题标题】:Create a Map of Building Indoors for Android Devices为 Android 设备创建室内建筑地图
【发布时间】:2017-08-08 14:55:16
【问题描述】:

我被要求制作一个应用程序,帮助学生在学术街区内以最短的路线导航到他的班级。但是问题是,如何创建这样的地图,其中包含房间、楼层以及如果可能的话, 校园内所有建筑物的详细室内地图?

【问题讨论】:

  • 当然。您可以在地图上绘制(多边形)线;它们可以与建筑物的墙壁相匹配。你的问题到底是什么?另一件事是 GPS 的准确性。可能这在室内不够准确。你有建筑物的建筑平面图(也许是简化的)?您可以添加交换地板的按钮
  • 我的意思是,我需要创建一个有多个楼层和房间的建筑物的室内地图。是的,我可以向用户询问楼层,但之后,他应该会看到一张包含他的位置的地图和他注定的房间。然后我会应用 dijkstra Algo 以获得最短路径。地图的创建是障碍。请帮助。

标签: android google-maps android-fragments maps shortest-path


【解决方案1】:

我可以举一个网络例子;我不懂android编程

它包含 1 栋建筑,有几个房间。和按钮来选择级别。或许能给你一些启发。

我猜你需要一些高程数据。
对于导航,请考虑楼梯和电梯。

<!DOCTYPE html>
<html>
<head>
<title>Indoor Map</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
    html,
    body {
        height: 100%;
        margin: 0;
        padding: 0;
    }
    #map {
        height: 80%;
    }

</style>
<script>
    var map;
    var infowindow;
    var buildingPolyLine;
    var roomsPolylines = [];
    var activeLevel = 0;

    // VUB - Brussels university - Building G with a few rooms
    var building = {
        "name": "Building G",
        "color": "#ff0000",
        nodes: [
            [50.8217232994024, 4.397075700799178],
            [50.82232714536237, 4.3975462942398735],
            [50.8224010730568, 4.397200047969818],
            [50.82182496608163, 4.396712368707085]
        ]
    };

    var rooms = [{
            "name": "Parking",
            "level": "0",
            "color": "#0000ff",
            nodes: [
                [50.82230750704816, 4.397481197138404],
                [50.82235988170447, 4.397291001687336],
                [50.822044870401214, 4.397048382465982],
                [50.82199380856154, 4.39725003087915]
            ]
        },
        {
            "name": "1G003",
            "level": "1",
            "color": "#0000ff",
            nodes: [
                [50.82234196105868, 4.397353604435921],
                [50.82231750839912, 4.397428280481108],
                [50.82223654023366, 4.397366375092133],
                [50.822261380536176, 4.397290787105703]
            ]
        },
        {
            "name": "1G009",
            "level": "1",
            "color": "#0000ff",
            nodes: [
                [50.82219283244282, 4.397244183713838],
                [50.82216991951639, 4.397315503651953],
                [50.82211850835268, 4.397274663667758],
                [50.822140266976895, 4.397204862530089]
            ]
        },
        {
            "name": "2G10",
            "level": "2",
            "color": "#0000ff",
            nodes: [
                [50.8223601104488, 4.397285516533884],
                [50.82230697331296, 4.3974744915340125],
                [50.82215986306273, 4.397342808561007],
                [50.8222137798275, 4.3971696853441244]
            ]
        }
    ];

    // return a polyline.   If you give 2 points, it will simply be a line
    function makePolyline(points, color, close, title, visible) {
        if (close) {
            points.push(points[0]); // closed polyline, ...
        }
        var onMap = visible ? map : null;
        return new google.maps.Polyline({
            path: points,
            //geodesic: true,
            strokeColor: color, // '#FF0000',
            strokeOpacity: 1.0,
            strokeWeight: 2,
            title: title,
            map: onMap // we will let the Level buttons turn on the right rooms
        });
    }
    function initMap() {
        var myLocation = {
            lat: 50.822,
            lng: 4.397
        };
        map = new google.maps.Map(document.getElementById('map'), {
            center: myLocation,
            zoom: 17
        });
        // plot building
        var points = [];
        for (var i in building.nodes) {
            points.push({
                lat: building.nodes[i][0],
                lng: building.nodes[i][1]
            });
        }
        var buildingPolyLine = makePolyline(points, building.color, true, building.name, true);
        // plot building
        for (var j in rooms) {
            points = [];
            for (var i in rooms[j].nodes) {
                points.push({
                    lat: rooms[j].nodes[i][0],
                    lng: rooms[j].nodes[i][1]
                });
            }
            roomsPolylines.push(makePolyline(points, rooms[j].color, true, rooms[j].name, false));
        }
        // activate level 0
        setLevel(0);
    }
    function setLevel(level) {
        for (var j in rooms) {
            if (level == rooms[j].level) {
                roomsPolylines[j].setMap(map);
            } else {
                roomsPolylines[j].setMap(null);
            }
        }
    }
</script>
</head>
<body>
  <div id="map"></div>
  Level
  <input type="button" onclick="setLevel(0)" value="0" />
  <input type="button" onclick="setLevel(1)" value="1" />
  <input type="button" onclick="setLevel(2)" value="2" />
  <script src="https://maps.googleapis.com/maps/api/js?callback=initMap" async defer></script>
</body>
</html>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多