当前位置: 首页 > news >正文

设计网站栏目怎么建个人网站

设计网站栏目,怎么建个人网站,产品网络推广的方法有哪些,郑州网站备案目录 1. 项目结构 2. Maven依赖配置 (pom.xml) 3. 实现后端服务 4. 配置文件 (application.properties) 5. 启动项目 6. 访问页面 实现基于北斗卫星的车辆定位和轨迹图的Maven工程(使用模拟数据),我们将使用以下技术: Spri…

目录

1. 项目结构

2. Maven依赖配置 (pom.xml)

3. 实现后端服务

 4. 配置文件 (application.properties) 

5. 启动项目

6. 访问页面


实现基于北斗卫星的车辆定位和轨迹图的Maven工程(使用模拟数据),我们将使用以下技术:

  • Spring Boot:作为后端框架,用来提供数据接口。
  • Thymeleaf:作为前端模板引擎,呈现网页。
  • Leaflet.js:一个开源的JavaScript库,用于显示交互式地图。
  • Simulated Data:使用随机生成的模拟GPS数据来模拟北斗卫星车辆位置。
  • WebSocket:用于实现实时数据推送,确保地图位置每秒更新。

1. 项目结构

创建一个Maven项目,基本结构如下:

项目结构图: 

2. Maven依赖配置 (pom.xml)

首先在pom.xml中添加必要的依赖,确保使用Spring Boot、WebSocket和Thymeleaf:

<dependencies><!-- Spring Boot --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><!-- Thymeleaf for rendering HTML --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-thymeleaf</artifactId></dependency><!-- WebSocket for real-time communication --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-websocket</artifactId></dependency><!-- Lombok (Optional, for cleaner code) --><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><scope>provided</scope></dependency>
</dependencies>

3. 实现后端服务

package com.example.beidou;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;@SpringBootApplication
@EnableScheduling  // 启用定时任务
public class BeidouApplication {public static void main(String[] args) {SpringApplication.run(BeidouApplication.class, args);}
}
效果图:
Controller:
package com.example.beidou.controller;import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RestController;import java.util.HashMap;
import java.util.Map;
import javax.annotation.PostConstruct;@RestController
public class VehicleController {@Autowiredprivate SimpMessagingTemplate messagingTemplate;private Map<String, Map<String, Double>> vehiclePositions = new HashMap<String, Map<String, Double>>() {{put("Vehicle 1", new HashMap<String, Double>() {{put("latitude", 39.9042);//北京put("longitude", 116.4074);}});put("Vehicle 2", new HashMap<String, Double>() {{put("latitude", 31.2304);//上海put("longitude", 121.4737);}});put("Vehicle 3", new HashMap<String, Double>() {{put("latitude", 22.3964);// 香港put("longitude", 114.1095);}});put("Vehicle 4", new HashMap<String, Double>() {{put("latitude", 30.5728);//成都put("longitude", 104.0668);}});put("Vehicle 5", new HashMap<String, Double>() {{put("latitude", 34.3416);// 西安put("longitude", 108.9398);}});}};private Map<String, Map<String, Double>> vehicleTargets = new HashMap<String, Map<String, Double>>() {{put("Vehicle 1", new HashMap<String, Double>() {{put("latitude", 31.2304);//上海put("longitude", 121.4737);}});put("Vehicle 2", new HashMap<String, Double>() {{put("latitude", 39.9042);//北京put("longitude", 116.4074);}});put("Vehicle 3", new HashMap<String, Double>() {{put("latitude", 34.3416);// 西安put("longitude", 108.9398);}});put("Vehicle 4", new HashMap<String, Double>() {{put("latitude", 22.3964);// 香港put("longitude", 114.1095);}});put("Vehicle 5", new HashMap<String, Double>() {{put("latitude", 30.5728);//成都put("longitude", 104.0668);}});}};// 服务器启动时自动启动模拟@PostConstructpublic void startSimulation() {System.out.println("Starting vehicle simulation...");}// 模拟车辆移动轨迹@Scheduled(fixedRate = 1000)private void sendVehicleUpdates() {Map<String, Map<String, Double>> updatedPositions = new HashMap<>();for (Map.Entry<String, Map<String, Double>> entry : vehiclePositions.entrySet()) {String vehicleId = entry.getKey();Map<String, Double> position = entry.getValue();Map<String, Double> target = vehicleTargets.get(vehicleId);// 按一定速度向目标移动double latDiff = target.get("latitude") - position.get("latitude");double lonDiff = target.get("longitude") - position.get("longitude");// 每次移动经纬度的 1/100double newLatitude = position.get("latitude") + latDiff * 0.02;double newLongitude = position.get("longitude") + lonDiff * 0.02;position.put("latitude", newLatitude);position.put("longitude", newLongitude);updatedPositions.put(vehicleId, new HashMap<>(position));}messagingTemplate.convertAndSend("/topic/vehicleLocation", updatedPositions);}
}

WebSocketConfig : 

package com.example.beidou.config;import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {@Overridepublic void configureMessageBroker(MessageBrokerRegistry config) {config.enableSimpleBroker("/topic");  // 使用 "/topic" 作为消息前缀config.setApplicationDestinationPrefixes("/app");}@Overridepublic void registerStompEndpoints(StompEndpointRegistry registry) {registry.addEndpoint("/vehicle-location").setAllowedOriginPatterns("*").withSockJS();}
}

 4. 配置文件 (application.properties) 

server.port=8080

5. 启动项目

确保你有Java和Maven环境,在项目根目录执行以下命令启动应用:

mvn spring-boot:run

6. 访问页面

在浏览器中访问 http://localhost:8080,你应该可以看到一个地图,显示车辆的实时位置和轨迹更新。

前端页面代码有需要的,请私信我,有偿提供代码,白嫖党勿扰! 

http://www.yayakq.cn/news/367261/

相关文章:

  • 一家专门做打折的网站山东智慧团建官网
  • 抓好门户网站建设wordpress mysql 扩展
  • 青海中小企业网站建设大良网站建设机构
  • 网页代理访问网站之梦网站怎么做seo
  • delphi 网站开发仿卢松松博客wordpress
  • 哪个做砍价活动的网站好深圳旅游
  • 电子商务网站购物流程图微信开放平台怎么申请
  • 招聘网站做两份简历电子商务软文写作
  • 成都网站seo技术流程图在线制作免费
  • 广州市手机网站建设品牌成品视频直播软件推荐哪个好一点的
  • 专业网站推广的公司网站被降权后怎么办
  • 网站建设都有什么功能济宁网站建设公司怎么样
  • 济南网站搜索排名thinkphp网站开发技术
  • 网站运营托管方案开公司需要什么手续和证件
  • 三原做网站深圳网页设计公司有哪些
  • 景安备案网站站长统计是什么意思
  • 怎么开发手机网站phpcms中英文网站模板
  • 河南专业网站建设哪家好建网站为什么要租空间
  • 做网站是如何实施的做网站商城需要什么
  • 网站设计建议网络营销策略应遵循的原则
  • 网站建设公司理念区块链技术做网站
  • 重庆网站建设公司是什么意思樱花jsq30q211
  • 怎样破解网站后台密码网站开发设计心得
  • 深圳市龙华区沈阳网站建设seo优化
  • 海拉尔网站建设平台vs怎样建设新网站
  • iis怎么加载网站英文搜索网站
  • 自己做微信电影网站怎么做转短链接在线生成
  • 网站建设的搜索功能美仑-专门做服装的网站
  • 贸易网站源码企业官网制作公司
  • 做网站跟客人怎么沟通西渡网站建设