qqmap 的一些操作
; var mapcontorl = "mapContainer";
var fullscreen = false; function qqMap(options) {
var that = this
, _mapInfowWin = null
, _newMarker = null
, _newLabel = null
, _oldMarker = null
, _oldLabel = null
, _allMarkers = []
, _allLabels = []
, _drowMarkers = []
, _clearOldMarker = true
, _allowDrag = true
, _map = null
, _searchService = null
, _polygon = null
, _newpolygon = null
, _anchor = null
, _offsetSize = null
, _panoContainerId = null
, _controlId = null
, _clickListener = null
, _rightBound = null
, _zoom
, _centerPoint
, _center
,_nearLandPolygons=[]; this.MarkerIconTypes =
{
MAP_old: '/Resource/Images/Skin/DPS/MAP_old.png',
MAP_PIN: '/Resource/Images/Skin/DPS/MAP_PIN.png',
MAP_PIN_other: '/Resource/Images/Skin/DPS/MAP_PIN_other.png',
MAP_PIN_grey: '/Resource/Images/Skin/DPS/MAP_PIN_grey.png',
MAP_PIN_purple: '/Resource/Images/Skin/DPS/MAP_PIN_purple.png'
};
this.markerImgPath = {
centerMarker: "/Resource/Images/Skin/DPS/red-flag.png", //中心点图标图片
preMarker: "/Resource/Images/Skin/DPS/not-sell.png", //预公告图标图片(非售)
notMarker: "/Resource/Images/Skin/DPS/unsold.png", //正式公告图标图片(未售)
nowMarker: "/Resource/Images/Skin/DPS/on-sale.png", //已成交公告图标图片(在售)
outMarker: "/Resource/Images/Skin/DPS/sold-out.png" //售馨
};
this.arrayObj = new Array(); //创建一个path数组
this.tuliId = null; //图例DivId
this.centerText = "当前土地位置"; //画圆中心点文字
this.OldPoint = options.OldPoint; //旧位置
this.oldPath = options.oldPath; //旧的多边形
this.Radius = 1000; _panoContainerId = options.panoContainerId == null ? "panoContainer" : options.panoContainerId;
_controlId = options.controlId == null ? "mapContainer" : options.controlId;
_zoom = options.zoom ? options.zoom : 12;
_centerPoint = Array.FindByPropertyValue(top.DictionaryCache.City, "Id", top.Cache.cityId, false).CityCenter;
_center = new qq.maps.LatLng("30.649821", "104.06697");
if (_centerPoint) {
_centerPoint = _centerPoint.replace('[', '').replace(']', '').split(',');
_center = new qq.maps.LatLng(_centerPoint[0], _centerPoint[1]);
}; //地图div
mapcontorl = _controlId; //初始化加载
_init(); //重新加载地图
this.IntMap = function() {
_clearOverlays(_allMarkers);
_clearOverlays(_allLabels);
_clearMarkerOrPolygon();
var point = new qq.maps.LatLng(that.OldPoint.Lat, that.OldPoint.Lng);
_oldMarker = _addMarker(that.OldPoint.Lat, that.OldPoint.Lng, true, "/Resource/Images/Skin/DPS/MAP_PIN.png", 17, 28);
//旧位置不允许拖动
_oldMarker.draggable = false;
_oldLabel = _addLabel(that.OldPoint.Lat, that.OldPoint.Lng, "旧位置");
if (that.arrayObj && that.arrayObj.length) {
//拖动坐标点
_moveMarker();
}
if (_newMarker) {
_newMarker.setMap(null);
_newLabel.setMap(null);
}
if (that.oldPath) {
_polygon = new qq.maps.Polygon({
clickable: true,
editable: true,
strokeColor: "#0066CC",
strokeWeight: 1,
strokeDashStyle: "solid",
fillColor: qq.maps.Color.fromHex("#0066CC", 0.2),
map: _map
});
for (var i = 0; i < that.oldPath.length; i++) {
//多边形每个角添加一个坐标点
var point = new qq.maps.LatLng(that.oldPath[i].lat, that.oldPath[i].lng);
_addDrowMarker(point);
}
}
}; //获取地图范围
this.getBound = function() {
return _resetBounds();
}; /*
* 在地图绘制标记
* data: 数据源(包含每个marker数据的对象数组)
* 每个marker对象数据格式:
* lat(必需),
* lng(必需),
* labelContent(非必需:marker label的html),
* MarkerIconTypes(非必需:qqMaps实例上具有该字典)
* polygonPath(非必需:描绘多边形的点数组)
*
* Liuning 41161885@qq.com
*/
this.addAroundPro = function (data) { this.clearNearLandMarkerObjs(); for (var i = 0, len = data.length; i < len; i++)
{
var marker,
label,
polyon,
o = data[i]; //添加marker lable
label = _addLabel(
o.lat,
o.lng,
(o.labelContent || null)
);
_allLabels.push(label); //绘制周边土地多边形
if (o.polygonPath) {
polyon = _drawNearLandPolygon(o.polygonPath);
_nearLandPolygons.push(polyon);
}; //添加marker
marker = _addMarker(
o.lat,
o.lng,
false,
(o.MarkerIconTypes || that.MarkerIconTypes.MAP_PIN_other),
17,
28,
false
);
_allMarkers.push(marker);
};
}; /*
*清除地图上的多边形(周边公告土地/周边预公告土地)
*/
this.clearNearLandMarkerObjs = function ()
{
_clearOverlays(_allMarkers);
_clearOverlays(_allLabels);
_clearNearLandPolygon();
}; //清除周边项目
this.clearPro = function () {
_clearOverlays(_allMarkers);
_clearOverlays(_allLabels);
}; //地图搜索(keywordId代表输入的关键字)
this.getResult = function (keywordId) {
//设置searchRequest
var poiText = document.getElementById(keywordId).value;
_searchService.setLocation(Array.FindByPropertyValue(top.DictionaryCache.City, "Id", top.Cache.cityId, false).CityName);
_searchService.search(poiText);
}; //地图标点
this.mapClick = function (GetGeomInfo) {
_clearOldMarker = false;
_clearNewMarkerPolygon();
_newpolygon = null; //移除画图事件
if (_clickListener) {
qq.maps.event.removeListener(_clickListener);
} _map.setOptions({ "draggableCursor": "/Resource/Images/Skin/DPS/select.cur", "draggingCursor": "/Resource/Images/Skin/DPS/select.cur" });
_clickListener = qq.maps.event.addListener(_map, 'click', function (e) {
var p = {};
p.lat = e.latLng.lat;
p.lng = e.latLng.lng; if (_newMarker) {
var nowpoint = new qq.maps.LatLng(e.latLng.lat, e.latLng.lng);
_newMarker.setPosition(nowpoint);
_newLabel.setPosition(nowpoint);
_newMarker.setMap(_map);
_newLabel.setMap(_map);
}
else {
_newMarker = _addMarker(e.latLng.lat, e.latLng.lng, false, "/Resource/Images/Skin/DPS/MAP_old.png", 17, 28);
_newLabel = _addLabel(e.latLng.lat, e.latLng.lng, "新位置");
} //拖动坐标点
qq.maps.event.addListener(_newMarker, 'position_changed', function (e) {
_newLabel.setPosition(_newMarker.position);
}); qq.maps.event.addListener(_newMarker, "dragend", function (e) {
GetGeomInfo(e.latLng);
}); //如果需要处理根据坐标的查询对应的板块等基本信息(GetGeomInfo为页面方法)
if (GetGeomInfo) {
GetGeomInfo(p);
}
});
}; this.ClearAllFlagsOnMap = function () {
_clearMarkerOrPolygon();
}; //画多边形
this.drawPolygon = function () {
_clearNewMarkerPolygon();
that.arrayObj = new Array();
_map.setOptions({ "draggableCursor": "hand" }); _newpolygon = new qq.maps.Polygon({
clickable: true,
editable: true,
strokeColor: "#0066CC",
strokeWeight: 1,
strokeDashStyle: "solid",
fillColor: qq.maps.Color.fromHex("#0066CC", 0.2),
map: _map
}); //移除画图事件
if (_clickListener) {
qq.maps.event.removeListener(_clickListener);
} _clickListener = qq.maps.event.addListener(_map, "click", function (e) {
var point = new qq.maps.LatLng(e.latLng.getLat(), e.latLng.getLng());
_addDrowMarker(point, _clickListener, _newpolygon);
});
}; //显示圆
this.drawCircle = function (params) {
try {
if (hasCenter) {
if (!hasCenter) {
that.centerText = "";
}
}
} catch (e) { };
_center = new qq.maps.LatLng(that.OldPoint.Lat, that.OldPoint.Lng);
var circle = new qq.maps.Circle({
map: _map,
center: _center,
radius: that.Radius,
radius: 1000,
strokeColor: "#0066CC",
strokeWeight: 1,
strokeDashStyle: "solid",
fillColor: qq.maps.Color.fromHex("#0066CC", 0.2)
});
_oldMarker.setMap(null);
_oldLabel.setMap(null);
_allowDrag = false;
_anchor = new qq.maps.Point(5, 45);
//中心坐标
_map.setCenter(_center);
var centerMarker = _addMarker(_center.lat, _center.lng, true, "/Resource/Images/Skin/DPS/red-flag.png", 42, 53);
_offsetSize = new qq.maps.Size(-35, 2);
var clabel = _addLabel(_center.lat, _center.lng, "<span style='color:red;'>" + that.centerText + "</span>");
if (params && (params.UseAreaMu || params.LLandUseType)) {
centerMarker.setTitle("净用地面积:" + params.UseAreaMu + "亩,土地用途分类:" + params.LLandUseType);
}
//绘制圆半径
_rightBound = new qq.maps.LatLng(_center.getLat(), circle.getBounds().getNorthEast().getLng());
var polyline = new qq.maps.Polyline({
path: [_center, _rightBound],
strokeWeight: 1,
editable: false,
map: _map
});
//显示半径文字
_offsetSize = null;
var label = _addLabel(_rightBound.lat, _rightBound.lng, "1000米");
qq.maps.event.addListener(label, 'mouseover', function (e) {
_map.setOptions({ "draggableCursor": "hand" });
});
//最右边的点
_anchor = null;
_allowDrag = true;
var rightMarker = _addMarker(_rightBound.lat, _rightBound.lng, false, "http://s.map.soso.com/themes/default/img/dot.png?v=v3.3.786", 12, 12);
qq.maps.event.addListener(rightMarker, 'position_changed', function (e) {
var nowPoint = new qq.maps.LatLng(e.target.position.lat, e.target.position.lng);
var num = parseInt(_center.distanceTo(nowPoint));
circle.setRadius(num);
label.setContent(num + "米");
label.setPosition(nowPoint);
polyline.setPath([_center, nowPoint]);
that.Radius = num;
}); qq.maps.event.addListener(rightMarker, 'mouseup', function (e) {
if (getData) {
_rightBound = new qq.maps.LatLng(e.latLng.lat, e.latLng.lng);
getData();
}
});
//图例
//显示提示信息
var customShowDiv = document.getElementById(that.tuliId);
_map.controls[qq.maps.ControlPosition.BOTTOM_RIGHT].push(customShowDiv);
}; //根据中心点、右边的点和半径获取像素距离
this.getPath = function () {
var projection = _map.getProjection();
var point = projection.fromLatLngToPoint(_center); //projection.fromLatLngToPoint(center, map.getZoom());
var rightpoint = projection.fromLatLngToPoint(_rightBound); //projection.fromLatLngToPoint(rightBound, map.getZoom());
var len = point.distanceTo(rightpoint);
return _generateCirclePoints(_map, _center, len);
}; //土地或者项目关联的标点
this.DrawProOrLandMarker = function (type, data) {
var infoTpl = $("#divInfolandTemplate").comment();
var labelText = "", nlabel;
if (type == "land") {
infoTpl = $("#divInfolandTemplate").comment();
labelText = "<div style='text-align:center;color:#000;font-family:微软雅黑,宋体;font-size:11px;cursor:pointer;*cursor:hand;'>" + data.ShowT.toString() + "亩" + "</div>";
nlabel = _addLabel(data.lat, data.lng, labelText);
} else {
infoTpl = $("#divInfoprojectTemplate").comment();
labelText = "<div style='text-align:center;color:#000;font-family:微软雅黑,宋体;font-size:11px;cursor:pointer;*cursor:hand;'>" + data.ProjectSquare + "亩" + "</div>";
if (data.ProjectSquare) {
nlabel = _addLabel(data.lat, data.lng, labelText);
}
} _allowDrag = false;
var nmarker = _addMarker(data.lat, data.lng, false, data.marker, 32, 42);
_offsetSize = new qq.maps.Size(18, -30); if (nlabel) {
qq.maps.event.addListener(nlabel, 'click', function (args) {
nlabel.setStyle("cursor", "hand");
});
nlabel.DataItem = data;
qq.maps.event.addListener(nlabel, 'click', function (args) {
var data = args.target.DataItem;
if (data.BaseInfoName && data.BaseInfoId) {
infoTpl = infoTpl.replace("style='display:none'", "");
}
_mapInfowWin.open();
_mapInfowWin.setContent(String.FormatByEmptyValue(infoTpl, "--", data));
_mapInfowWin.setPosition(new qq.maps.LatLng(data.lat, data.lng));
});
_allLabels.push(nlabel);
} nmarker.DataItem = data;
qq.maps.event.addListener(nmarker, 'click', function (args) {
var data = args.target.DataItem;
if (data.BaseInfoName && data.BaseInfoId && type == "land") {
infoTpl = infoTpl.replace("style='display:none'", "");
}
_mapInfowWin.open();
_mapInfowWin.setContent(String.FormatByEmptyValue(infoTpl, "--", data));
_mapInfowWin.setPosition(new qq.maps.LatLng(data.lat, data.lng));
});
_allMarkers.push(nmarker);
}; //清空页面填充的数据
this.ClearMarkerAndLabel = function () {
_clearOverlays(_allMarkers);
_clearOverlays(_allLabels);
}; //关闭弹出窗口
this.closeWin = function() {
_mapInfowWin.close();
}; //列表选择行后地图显示对应的项
this.openWin = function(type, data) {
var infoTpl = "";
if (type == "land") {
infoTpl = $("#divInfolandTemplate").comment();
if (data.BaseInfoName && data.BaseInfoId) {
infoTpl = infoTpl.replace("style='display:none'", "");
}
} else if (type == "project") {
infoTpl = $("#divInfoprojectTemplate").comment();
} _mapInfowWin.open();
_mapInfowWin.setContent(String.FormatByEmptyValue(infoTpl, "--", data));
_mapInfowWin.setPosition(new qq.maps.LatLng(data.lat, data.lng));
}; //更新marker状态
this.ChangeMarker = function(i, data) {
var marker = _allMarkers[i];
marker.DataItem = data;
var anchor0 = _anchor == null ? new qq.maps.Point(16, 36) : _anchor;
var size0 = new qq.maps.Size(32, 40),
origin0 = new qq.maps.Point(0, 0),
icon0 = new qq.maps.MarkerImage(data.marker, size0, origin0, anchor0);
marker.setIcon(icon0);
}; //或者两个经纬度之间的距离
this.getDistanceByLatLng = function (lat, lng) {
var latLng = new qq.maps.LatLng(lat, lng);
return _center.distanceTo(latLng);
}; //定位地图中心坐标点
this.setCenterMap = function (lat, lng) {
if (lat && lng) {
_map.setCenter(new qq.maps.LatLng(lat, lng));
}
else {
if (_centerPoint) {
_map.setCenter(new qq.maps.LatLng(_centerPoint[0], _centerPoint[1]));
_map.setZoom(11);
};
}
}; /*
*Liuning
*获取当前地图视野范围内的中心店,返回一个数组,arr[0]:Lat arr[1]: Lng
*/
this.getMapViewCenter = function () {
var arr = [];
var center = _map.getCenter();
arr.push(center.getLat());
arr.push(center.getLng());
return arr;
}; //加载地图操作
function _init() {
_map = new qq.maps.Map(document.getElementById(_controlId), {
center: _center,
zoom: _zoom,
disableDefaultUI: false
});
//地图检索服务
_searchService = new qq.maps.SearchService({
map: _map
});
//全屏
new qq.maps.Control(
{
content: "<span class='map-btn fullScreen' id='J_FullScreen' onclick='SetFullScreen()'>全屏</span>",
align: qq.maps.ALIGN.TOP_RIGHT,
margin: new qq.maps.Size(5, 10),
zoom: _zoom,
map: _map
});
//切换地图类型
qq.maps.event.addListener(_map, 'maptypeid_changed', function (e) {
if (_map.getMapTypeId() == "街景") {
$("#" + _controlId + " > div > div:lt(3)").hide();
$("#" + _controlId).children().append($("#" + _panoContainerId));
$("#" + _panoContainerId).show();
}
else {
$("#" + _controlId + " > div > div:lt(3)").show();
$("#" + _panoContainerId).hide();
}
});
//旧位置
if (options.OldPoint) {
_oldMarker = _addMarker(options.OldPoint.Lat, options.OldPoint.Lng, true, "/Resource/Images/Skin/DPS/MAP_PIN.png", 17, 28);
_oldMarker.draggable = false;
_oldLabel = _addLabel(options.OldPoint.Lat, options.OldPoint.Lng, "旧位置");
if (options.oldPath) {
//拖动坐标点
_moveMarker();
}
};
//旧的多边形
if (options.oldPath) {
_polygon = new qq.maps.Polygon({
clickable: true,
editable: true,
strokeColor: "#0066CC",
strokeWeight: 1,
strokeDashStyle: "solid",
fillColor: qq.maps.Color.fromHex("#0066CC", 0.2),
map: _map
});
for (var i = 0; i < options.oldPath.length; i++) {
//多边形每个角添加一个坐标点
var point = new qq.maps.LatLng(options.oldPath[i].lat, options.oldPath[i].lng);
_addDrowMarker(point);
};
};
qq.maps.event.addListener(_map, 'bounds_changed', _resetBounds); //地图弹出窗口
_mapInfowWin = new soso.maps.InfoWindow({
map: _map
});
//地图弹出窗口关闭
soso.maps.event.addListener(_map, 'click', function () {
_mapInfowWin.close();
});
}; //获取当前地图范围位置
function _resetBounds() {
var bounds = _map.getBounds();
var bound = {};
if (bounds) {
bound.NorthEast_X = bounds.getNorthEast().getLng();
bound.NorthEast_Y = bounds.getNorthEast().getLat();
bound.SouthWest_X = bounds.getSouthWest().getLng();
bound.SouthWest_Y = bounds.getSouthWest().getLat();
}
return bound;
}; /* 添加marker
*lat 纬度
*lng 经度
*moveToCenter 是否设置为中心点
*ImgUrl 图片路径
*width 图片宽度
*height 图片高度
*allowDrag是否允许拖动
*/
function _addMarker(lat, lng, moveToCenter, imgUrl, width, height, allowDrag)
{
//使用默认的icon
var anchor0 = _anchor||new qq.maps.Point(width / 2, height - 4);
var size0 = new qq.maps.Size(width, height);
var origin0 = new qq.maps.Point(0, 0);
var icon0 = new qq.maps.MarkerImage(imgUrl, size0, origin0, anchor0);
var marker0 = new qq.maps.Marker({
icon: icon0,
map: _map,
draggable: allowDrag==null ? _allowDrag:allowDrag,
position: new qq.maps.LatLng(lat, lng)
});
//设置marker点击事件:点击时隐藏label ,再点击就显示label
qq.maps.event.addListener(marker0, "click", function (e)
{
var label=null;
var latLng = e.latLng; for (var i = 0, len = _allMarkers.length; i < len; i++) {
label = _allLabels[i];
if (latLng.equals(label.getPosition())) break;
}; if (!label) return; var visible = label.getVisible()
if (visible) {
label.setVisible(false);
} else {
label.setVisible(true);
}
}); moveToCenter && _map.setCenter(new qq.maps.LatLng(lat, lng));
return marker0;
}; /* 添加lable
*lat 纬度
*lng 经度
*showText 显示的文字
*/
function _addLabel(lat, lng, showText) {
var size = new qq.maps.Size(10, -25);
if (_offsetSize) size = _offsetSize; var label = new qq.maps.Label({
position: new qq.maps.LatLng(lat, lng),
map: _map,
content: showText.toString(),
offset: size
}); return label;
}; /*
*绘制周边土地多边形
*data:用于描绘多边形的点数组
*/
function _drawNearLandPolygon(data) {
var path = [];
for (var i = 0; i < data.length; i++) {
var item = data[i];
var point = new qq.maps.LatLng(item.lat, item.lng);
path.push(point);
};
var _polygon = new qq.maps.Polygon({
path: path,
clickable: true,
editable: false,
strokeColor: "#0066CC",
strokeWeight: 1,
strokeDashStyle: "solid",
map: _map
}); return _polygon;
}; function _addDrowMarker(point, listener, polygonSource) {
var marker = _addMarker(point.lat, point.lng, false, "/Resource/Images/Skin/DPS/map_ponit.png", 8, 8); _drowMarkers.push(marker);
that.arrayObj.push(point); if (!polygonSource) {
polygonSource = _polygon;
} polygonSource.setPath(that.arrayObj);
marker.setTitle(that.arrayObj.length - 1); //停止画多边形
var dlistener = qq.maps.event.addListener(marker, "dblclick", function (e) {
var newLabelcontent = "新位置【" + (qq.maps.geometry.spherical.computeArea(that.arrayObj) * 3 / 2000).toFixed(2) + "亩】";
var point = polygonSource.getBounds().getCenter();
if (_newMarker) {
_newMarker.setPosition(point);
_newLabel.setPosition(point);
_newMarker.setMap(_map);
_newLabel.setMap(_map);
_newLabel.content = newLabelcontent;
} else {
_newMarker = _addMarker(point.lat, point.lng, false, "/Resource/Images/Skin/DPS/MAP_old.png", 17, 28);
_newLabel = _addLabel(point.lat, point.lng, newLabelcontent);
} qq.maps.event.addListener(_newMarker, "dragend", function (e) {
GetGeomInfo(e.latLng, that.arrayObj);
}); //移除画图事件
if (listener) {
qq.maps.event.removeListener(listener);
} qq.maps.event.removeListener(dlistener);
_moveMarker();
if (GetGeomInfo) {
GetGeomInfo(point, that.arrayObj);
};
}); //修改多边形
qq.maps.event.addListener(marker, 'position_changed', function (e) {
//debugger;
var newLabelcontent = "新位置【" + (qq.maps.geometry.spherical.computeArea(that.arrayObj) * 3 / 2000).toFixed(2) + "亩】";
var point = polygonSource.getBounds().getCenter();
if (!_newMarker) {
_newMarker = _addMarker(point.lat, point.lng, false, "/Resource/Images/Skin/DPS/MAP_old.png", 17, 28);
_newLabel = _addLabel(point.lat, point.lng, newLabelcontent);
} else {
_newMarker.setPosition(point);
_newLabel.setPosition(point);
_newMarker.setMap(_map);
_newLabel.setMap(_map);
_newLabel.content = newLabelcontent;
}
if (_oldMarker) {
_oldMarker.setVisible(false);
_oldLabel.setVisible(false);
}
_moveMarker();
var index = marker.getTitle();
that.arrayObj[index].lat = marker.position.lat;
that.arrayObj[index].lng = marker.position.lng;
polygonSource.setPath(that.arrayObj);
if (GetGeomInfo) {
GetGeomInfo(point, that.arrayObj);
};
});
}; //清除地图上的标记
function _clearOverlays(overlays) {
var overlay;
while (overlay = overlays.pop()) {
overlay.setMap(null);
}
}; //清除多边形或者清除标点
function _clearMarkerOrPolygon() { if (_newpolygon) {
_clearOverlays(_drowMarkers);
_drowMarkers = [];
_newpolygon.setMap(null);
_newpolygon.path = null;
}
if (_polygon) {
_clearOverlays(_drowMarkers);
_drowMarkers = [];
_polygon.setPath([]);
_polygon = null;
}
if (_newMarker) {
_newMarker.setMap(null);
_newLabel.setMap(null);
}
if (_oldMarker && _clearOldMarker) {
_oldMarker.setMap(null);
_oldLabel.setMap(null);
} _clearOverlays(_allMarkers);
_clearOverlays(_allLabels);
}; function _clearNewMarkerPolygon() {
if (_newMarker) {
_newMarker.setMap(null);
_newLabel.setMap(null);
}
if (_newpolygon) {
_clearOverlays(_drowMarkers);
_drowMarkers = [];
_newpolygon.setMap(null);
_newpolygon = null;
}
}; function _clearNearLandPolygon()
{
while (o = _nearLandPolygons.pop()) {
if (!o) break;
o.setMap(null);
o.setPath([]);
}
}; //拖动坐标点
function _moveMarker() {
if (_newMarker) {
qq.maps.event.addListener(_newMarker, 'position_changed', function (e) {
_newLabel.setPosition(_newMarker.position);
});
}
if (_oldMarker) {
qq.maps.event.addListener(_oldMarker, 'position_changed', function (e) {
_oldLabel.setPosition(_oldMarker.position);
});
}
}; /// <summary>以指定坐标为中心计算圆指定精度下的所有坐标点</summary>
/// <param name="map" type="Map">SOSO地图对象(V2.0)</param>
/// <param name="center" type="LatLng">中心坐标</param>
/// <param name="r" type="Number">圆的半径</param>
/// <param name="percision" type="Number">计算圆周坐标时的精度(每隔多少弧度计算一个点,默认0.5)</param>
function _generateCirclePoints(map, center, r, percision) {
if (!map || !center || r <= 0) {
return null;
};
if (!percision || percision < 0) {
percision = 1;
};
var points = [];
var pointstr = "";
var zoom = map.getZoom();
var projection = map.getProjection();
var latLngOffset = function (latLng, offsetX, offsetY) {
var point = projection.fromLatLngToPoint(latLng); // projection.fromLatLngToPoint(latLng, zoom);
point.x += offsetX;
point.y += offsetY;
return projection.fromPointToLatLng(point, zoom);
}; for (var angle = 0; angle <= 360; angle += percision) {
var x, y;
var point;
var rad = angle * Math.PI / 180;
y = Math.abs(Math.sin(rad) * r);
x = Math.abs(Math.cos(rad) * r);
point = latLngOffset(center, x, y);
if (angle <= 90) {
point = latLngOffset(center, x, 0 - y, zoom);
}
else if (angle > 90 && angle <= 180) {
point = latLngOffset(center, 0 - x, 0 - y, zoom);
}
else if (angle > 180 && angle <= 270) {
point = latLngOffset(center, 0 - x, y, zoom);
}
else if (angle > 270 && angle <= 360) {
point = latLngOffset(center, x, y, zoom);
};
pointstr += point.lng + " " + point.lat + ",";
points.push(point);
}; pointstr += points[0].lng + " " + points[0].lat;
return pointstr;
};
}; //全屏操作
function SetFullScreen() {
if (!fullscreen) {
fullscreen = true;
$("#" + mapcontorl).fullScreen({ type: "max" });
$("#J_FullScreen").removeClass().addClass("map-btn exit").text("退出");
}
else {
fullscreen = false;
$("#" + mapcontorl).fullScreen({ type: "min" });
$("#J_FullScreen").removeClass().addClass("map-btn fullScreen").text("全屏"); try {
if (!fullScreenFlag) {
$mapContainer.width(mapW1);
}
else {
$mapContainer.width(mapW2);
}
} catch (e) { } };
};
简单的对qqmap进行了一些封装,方便使用。
qqmap 的一些操作的更多相关文章
- 【原】iOS学习之应用之间的操作
关于应用之间的相互操作,小编一直觉得非常高大上,在一次面试中被面试官一顿暴虐,今天小编就决定学习一下!经过一顿度娘,找到一些博客,不过都比较凌乱,我就打算自己整理一下! 首先要说的是每一个APP都可以 ...
- iOS学习之应用之间的操作(转发)
首先要说的是每一个APP都可以设置一个自己独有的URL,APP应用之间的操作就是通过这个URL来实现的! 1.如何配置自己应用的URL? 关于自己的URL,作为资深的程序猿都会想到 Info.plis ...
- 关于DOM的操作以及性能优化问题-重绘重排
写在前面: 大家都知道DOM的操作很昂贵. 然后贵在什么地方呢? 一.访问DOM元素 二.修改DOM引起的重绘重排 一.访问DOM 像书上的比喻:把DOM和JavaScript(这里指ECMScri ...
- Sql Server系列:分区表操作
1. 分区表简介 分区表在逻辑上是一个表,而物理上是多个表.从用户角度来看,分区表和普通表是一样的.使用分区表的主要目的是为改善大型表以及具有多个访问模式的表的可伸缩性和可管理性. 分区表是把数据按设 ...
- C# ini文件操作【源码下载】
介绍C#如何对ini文件进行读写操作,C#可以通过调用[kernel32.dll]文件中的 WritePrivateProfileString()和GetPrivateProfileString()函 ...
- js学习笔记:操作iframe
iframe可以说是比较老得话题了,而且网上也基本上在说少用iframe,其原因大致为:堵塞页面加载.安全问题.兼容性问题.搜索引擎抓取不到等等,不过相对于这些缺点,iframe的优点更牛,跨域请求. ...
- jquery和Js的区别和基础操作
jqery的语法和js的语法一样,算是把js升级了一下,这两种语法可以一起使用,只不过是用jqery更加方便 一个页面想要使用jqery的话,先要引入一下jqery包,jqery包从网上下一个就可以, ...
- ASP.NET Aries 入门开发教程7:DataGrid的行操作(主键操作区)
前言: 抓紧勤奋,再接再励,预计共10篇来结束这个系列. 上一篇介绍:ASP.NET Aries 入门开发教程6:列表数据表格的格式化处理及行内编辑 本篇介绍主键操作区相关内容. 1:什么时候有默认的 ...
- 如何在高并发环境下设计出无锁的数据库操作(Java版本)
一个在线2k的游戏,每秒钟并发都吓死人.传统的hibernate直接插库基本上是不可行的.我就一步步推导出一个无锁的数据库操作. 1. 并发中如何无锁. 一个很简单的思路,把并发转化成为单线程.Jav ...
随机推荐
- *[hackerrank]Maximizing XOR
https://www.hackerrank.com/contests/w1/challenges/maximizing-xor/ 找了半天规律,答案竟然是暴力,伤感.我找到的方法是利用规律2^x X ...
- [topcoder]LongLongTripDiv2
http://community.topcoder.com/stat?c=problem_statement&pm=13091 解方程,对中国孩子太简单了. #include <vect ...
- Debug过程中的mock (及display窗口的使用)
转载:http://m.blog.csdn.net/blog/u012516903/18004965 在debug的时候,有3个地方可以进行mock测试 测试代码如下: 1.使用display窗口 W ...
- JavaWeb项目开发案例精粹-第3章在线考试系统-001设计
1. 2. 3. 4. # MySQL-Front 5.0 (Build 1.0) /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE */; /*!40101 SET SQL ...
- player/stage 学习---安装
环境 ubuntu 14.04 一,工具安装 sudo apt-get install git cmake g++ fltk1.1-dev libjpeg8-dev libpng12-dev libg ...
- 利用PC创建一个无线接入点
win7 创建虚拟接入点,修改接入点名称和密码,然后存为bat文件,以管理员模式运行 netsh wlan set hostednetwork mode=allow ssid=APName key=p ...
- linux 开机自启动软件(包含xampp方法)
linux设置apache和mysql: linux开启启动的程序一般放在/etc/rc.d/init.d/里面,/etc/init.d/是其软连接. mysql设为linux服务 cp /usr/l ...
- Visaul Studio2015安装以及c++单元测试使用方法
Visual Studio 2015安装流程 vs2015是一款十分好用的IDE,接下来就介绍一下安装流程.这里采用在线安装方式,从官网下载使得安装更加安全. 第一步:在百度中搜索Visual ...
- Java基础——关键字
volatile 用volatile修饰的变量,线程在每次使用变量的时候,都会读取变量修改后的最的值.volatile很容易被误用,用来进行原子性操作. 对于volatile修饰的变量,jvm虚拟机只 ...
- gulp edm测试
gulp工具的 gulp-mailgun 插件可以将你的html代码,通过mailgun服务器来发送,用于测试,用这个工具发送邮件最适合不过了. 首先我们需要引入gulp和gulp-mailgun模块 ...