Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537
多小朋友喜歡用筆在紙上畫線進行走迷宮游戲。
比如下圖這種迷宮:從標(biāo)注了S(Start-起點)的位置出發(fā),走到終點E(End)就算成功。
那么,如何隨機生成上圖這種迷宮地圖呢?
我在github上部署了一個迷宮地圖生成應(yīng)用:http://i042416.github.io/FioriODataTestTool2014/WebContent/027_generator.html
每次進入這個應(yīng)用或者按F5刷新,就會隨機生成一張新的迷宮地圖:
這個應(yīng)用僅僅需要使用到兩個JavaScript腳本文件和一個html文件。
html文件的源代碼:
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
<meta http-equiv="Cache-Control" content="no-cache" />
<meta charset="utf-8">
<title>Maze Demo</title>
<!-- <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no, target-densitydpi=device-dpi" /> -->
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" />
<meta name="apple-mobile-web-app-title" content="H5Game">
<meta name="apple-touch-fullscreen" content="yes" >
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name='format-detection' content='telephone=no'>
<meta name="screen-orientation" content="portrait">
<meta name="full-screen" content="yes">
<meta name="x5-fullscreen" content="true">
<meta name="360-fullscreen" content="true">
<script type="text/javascript" src="maze//Maze.js"></script>
<script type="text/javascript" src="maze/main.js"></script>
<script type="text/javascript">
</script>
<style>
#toolbar {
position: absolute;
padding:2px;
top:0;
right:0;
width:180px;
}
#toolbar button {
padding:10px;
font-size:16px;
margin:5px;
}
</style>
</head>
<body>
<div id="container" class="splash">
<canvas id="canvas"></canvas>
<div id="info"></div>
</div>
</body>
</html>
迷宮的輪廓模型生成邏輯位于代碼Maze.js里:
"use strict";
var Maze = function(options) {
for (var p in options) {
this[p] = options[p];
}
}
先看效果,再看源碼~
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>創(chuàng)建地圖</title>
<style type="text/css">
html, body {
height: 100%;
margin: 0px;
padding: 0px;
}
#container {
width: 800px;
height: 600px;
}
</style>
</head>
<script charset="utf-8" src="https://wemapvis.map.qq.com/api/gljs?v=1.exp&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77"></script>
<body onload="initMap()">
<div id="container"></div>
<script type="text/javascript">
function initMap() {
//初始化地圖
var map = new TMap.Map("container", {
// 設(shè)置地圖縮放級別
zoom: 11,
rotation: 353,
pitch: 73,
// 地圖底圖,BaseMap目前只支持矢量底圖 (VectorBaseMap) 、衛(wèi)星底圖 (SatelliteBaseMap) 、路況底圖 (TrafficBaseMap)
// 可以使用數(shù)組形式實現(xiàn)多種底圖疊加
// 默認為 VectorBaseMap ,
baseMap:{
//type: "vector"
type: "satellite"
//type: "traffic"
},
// 3D / 2D 顯示模式控制
viewMode:'2D',
//設(shè)置地圖中心點坐標(biāo)
center: new TMap.LatLng(37.87, 112.53),
adcode: 110101 // 市區(qū)縣級行政區(qū)劃代碼
});
}
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>單擊事件獲取經(jīng)緯度</title>
<style type="text/css">
html, body {
height: 100%;
margin: 0px;
padding: 0px;
}
#container {
width: 800px;
height: 600px;
}
</style>
</head>
<script charset="utf-8" src="https://wemapvis.map.qq.com/api/gljs?v=1.exp&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77"></script>
<body onload="initMap()">
<div id="container"></div>
<script type="text/javascript">
function initMap() {
//初始化地圖
var map = new TMap.Map("container", {
// 設(shè)置地圖縮放級別
zoom: 11,
rotation: 353,
pitch: 73,
baseMap:{
//type: "vector"
type: "satellite"
//type: "traffic"
},
// 3D / 2D 顯示模式控制
viewMode:'2D',
//設(shè)置地圖中心點坐標(biāo)
center: new TMap.LatLng(37.87, 112.53),
adcode: 110101 // 市區(qū)縣級行政區(qū)劃代碼
});
//初始化marker
var marker = new TMap.MultiMarker({
map: map,
styles: {
// 點標(biāo)記樣式
marker: new TMap.MarkerStyle({
width: 20, // 樣式寬
height: 30, // 樣式高
anchor: { x: 10, y: 30 }, // 描點位置
src: 'https://mapapi.qq.com/web/lbs/javascriptGL/demo/img/markerDefault.png', // 標(biāo)記路徑
}),
},
geometries: [
// 點標(biāo)記數(shù)據(jù)數(shù)組
{
// 標(biāo)記位置(經(jīng)度,緯度,高度)
position: new TMap.LatLng(37.87, 112.53, 134),
},
],
});
//綁定點擊事件
map.on("click",function(evt){
var lat = evt.latLng.getLat().toFixed(6);
var lng = evt.latLng.getLng().toFixed(6);
console.log(lat + "," + lng);
})
}
</script>
</body>
</html>
慧景區(qū)AR導(dǎo)覽手繪地圖小程序系統(tǒng)開發(fā)源碼搭建需要以下步驟:
1. 確定系統(tǒng)需求和功能:了解智慧景區(qū)AR導(dǎo)覽手繪地圖小程序系統(tǒng)的需求和功能,包括地圖繪制、AR導(dǎo)覽、用戶交互、數(shù)據(jù)管理等。
2. 選擇開發(fā)平臺和工具:選擇適合的編程語言、開發(fā)框架、數(shù)據(jù)庫和云服務(wù)提供商等,搭建開發(fā)環(huán)境。
3. 設(shè)計系統(tǒng)架構(gòu):根據(jù)需求和功能設(shè)計系統(tǒng)架構(gòu),包括數(shù)據(jù)庫設(shè)計、系統(tǒng)模塊劃分、接口設(shè)計等。
4. 開發(fā)前端界面:使用HTML、CSS、JavaScript等前端技術(shù),開發(fā)手繪地圖和小程序界面,實現(xiàn)地圖繪制、AR導(dǎo)覽等功能。
5. 開發(fā)后端接口:使用后端編程語言和框架,開發(fā)與前端界面的交互接口,處理用戶請求、管理數(shù)據(jù)等。
6. 集成AR技術(shù):集成AR技術(shù)實現(xiàn)真實世界與虛擬元素的互動,為游客提供更好的導(dǎo)覽體驗。
7. 測試系統(tǒng):對搭建完成的系統(tǒng)進行全面測試,確保系統(tǒng)的穩(wěn)定性和功能性,解決測試過程中出現(xiàn)的問題。
8. 上線運營:完成測試后,將系統(tǒng)部署到云服務(wù)器上,進行上線運營,收集用戶反饋并進行優(yōu)化。
需要注意的是,智慧景區(qū)AR導(dǎo)覽手繪地圖小程序系統(tǒng)開發(fā)需要一定的技術(shù)能力和經(jīng)驗,建議選擇專業(yè)的開發(fā)團隊或公司進行開發(fā)。同時,需要考慮到系統(tǒng)的安全性和數(shù)據(jù)保護,確保系統(tǒng)的穩(wěn)定性和可靠性。
*請認真填寫需求信息,我們會在24小時內(nèi)與您取得聯(lián)系。