当前位置 : 主页 > 网络编程 > JavaScript >

批量顺序转换WGS2BD09

来源:互联网 收集:自由互联 发布时间:2021-06-28
gistfile1.txt var markerArr = [{"name":"A城","AQI":"84","index":"良","point":"106.5|28.4","Num":"2"},{"name":"B街","AQI":"97","index":"良","point":"106.4|27.3","Num":"2"},{"name":"C和","AQI":"87","index":"良","point":"106|27","Num":"2
gistfile1.txt
var markerArr = [
{
	"name":"A城",
	"AQI":"84",
	"index":"良",
	"point":"106.5|28.4",
	"Num":"2"
},
{
	"name":"B街",
	"AQI":"97",
	"index":"良",
	"point":"106.4|27.3",
	"Num":"2"
},
{
	"name":"C和",
	"AQI":"87",
	"index":"良",
	"point":"106|27",
	"Num":"2"
}]

//--------自定义图层设置
RectangleOverlay.prototype = new BMap.Overlay(); // 继承Overlay
RectangleOverlay.prototype.initialize = function(map) {
	this._map = map;
	this._overlayEl = document.createElement('div');
	this._overlayEl.className = this._className;
	this._overlayEl.style.zIndex = BMap.Overlay.getZIndex(this._mapPoint.lat); 
	this._labelEl = document.createElement('span');
	this._labelEl.className = this._className + '-label';
	this._labelEl.appendChild(document.createTextNode(this._label));
	this._overlayEl.appendChild(this._labelEl);
	this._map.getPanes().labelPane.appendChild(this._overlayEl);
	return this._overlayEl;
};
RectangleOverlay.prototype.draw = function() {
	var pixel = this._map.pointToOverlayPixel(this._mapPoint);
	// 计算矩形偏移
	var style = window.getComputedStyle(this._overlayEl);
	var overlayHeight = parseInt(style.height, 10);
	this._overlayEl.style.left = pixel.x + 'px';
	this._overlayEl.style.top = (pixel.y - overlayHeight) + 'px';
}; 
 
function RectangleOverlay(mapPoint, label, className) {
	this._mapPoint = mapPoint;
	this._label = label;
	this._className = className;
}    
     
//创建marker // 测试展现自定义覆盖物		
var i=0;
var t;
console.log('markerArr.length:'+markerArr.length);
function addlay(){
	console.log('A:'+i);			
	var jsona = markerArr[i];
	var lj = jsona.point.split("|")[0];
	var lw = jsona.point.split("|")[1];
	var mapPoint = new BMap.Point(lj,lw);
	var pointArr = [];
	pointArr.push(mapPoint); 
	//坐标转换完之后的回调函数			
	translateCallback= function (data){
		if(data.status === 0) {					
			mapPoint=data.points[0];					
			console.log('T:'+i);
			var json = markerArr[i];
			var iconImg = json.Num;
			var rectangleOverlay = new RectangleOverlay(mapPoint, json.name+" AQI:"+json.AQI+" "+json.index, 'point'+iconImg+'-overlay');
			map.addOverlay(rectangleOverlay);	
			i++;
			if(i
网友评论