场景 在页面中加载百度地图 数据模拟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);
}
}