場景 在頁面中加載百度地圖 數據模擬99棵樹木 加載每一顆樹木位置(採用覆蓋物) 患病-紅色 健康-黑色 鼠標懸浮覆蓋物顯示名稱
問題 1:百度API目前一次最多隻支持10個點座標轉換 超過時候data.status = 25 個數非法,超過限制(博客裏有說明)
問題 2:座標轉換的callback是異步的,若在for循環中調用則會使座標順序打亂 當數據超過10,覆蓋物顯示不了name屬性
解決辦法:
1.將大數組分成小數組存放,每次解決10個
2.將每次的異步請求記錄下
3.在springboot thymeleaf 注意在JS中使用轉義
測試案例採用springboot thymeleaf模版
部分結構如下
DemoBootApplication是啓動頁面
package com.tedu;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@MapperScan("com.tedu.dao")//掃描接口文件
@SpringBootApplication
public class DemoBootApplication {
public static void main(String[] args) {
SpringApplication.run(DemoBootApplication.class, args);
}
}