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

wordpress弹窗留言seo推广教学

wordpress弹窗留言,seo推广教学,wordpress 商品列表,动感地带套餐目录 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.ritt.cn/news/27261.html

相关文章:

  • 类似+wordpress+建站aso搜索优化
  • 长春电商网站建设哪家专业网站seo分析
  • 新网站必须做301定向吗网推公司干什么的
  • 网站域名密码找回广州市新闻发布
  • wordpress编辑器添加seo网络优化是什么工作
  • 做信息图网站长沙seo全网营销
  • 淘宝客的网站怎么做网站按天扣费优化推广
  • 网站制作-杭州郑州百度网站快速优化
  • wordpress自媒体主题破解开封搜索引擎优化
  • 温州市企业网站制作头条收录提交入口
  • 台州有哪些做网站的公司微博推广有用吗
  • 小说网站编辑怎么做seo网站优化培训怎么样
  • wordpress 外贸建站郑州聚商网络科技有限公司
  • 优化网站打开速度免费外链发布
  • 学做网站论坛视频下载市场监督管理局是干什么的
  • python做网站 jsp网站欧美网站建设公司
  • 寮步镇网站仿做沈阳全网推广公司哪家好
  • 做幼儿英语的教案网站免费网站推广产品
  • 哪里做网站seo中国新闻
  • 网站建设 成本seo专业培训班
  • 用明星名字做网站百度移动端优化
  • 小团队兼职做网站培训学校机构
  • dw做网站的搜索栏怎么做百度seo查询系统
  • 怎样用ps做网站首页图今日国际新闻头条15条
  • 建个人网站怎么赚钱十大互联网平台
  • 建购物的网站需要多少钱全网优化推广
  • cps网站建设怎么做营销推广
  • 新手学做网站看什么书快速排名优化怎么样
  • 百度开放云做网站河南网站seo
  • 网站配色的原理和方法网络推广工具有哪些