diff --git a/htmls/contactUs/contactUs.html b/htmls/contactUs/contactUs.html index e3cede5..f20dc42 100644 --- a/htmls/contactUs/contactUs.html +++ b/htmls/contactUs/contactUs.html @@ -20,7 +20,7 @@ #allmap { width: 100%; height: 100%; - + margin: 0; font-family: "微软雅黑"; } @@ -118,21 +118,66 @@ }); } - LoadBaiduMapScript().then((BMap)=>{ + LoadBaiduMapScript().then((BMap) => { // 百度地图API功能 + function SquareOverlay(center, length, color) { + this._center = center; + this._length = length; + this._color = color; + } var map = new BMap.Map("allmap"); // 创建Map实例 - map.centerAndZoom(new BMap.Point(116.404, 39.915), 11); // 初始化地图,设置中心点坐标和地图级别 - //添加地图类型控件 - map.addControl(new BMap.MapTypeControl({ - mapTypes: [ - BMAP_NORMAL_MAP, - BMAP_HYBRID_MAP - ] - })); - map.setCurrentCity("成都"); // 设置地图显示的城市 此项是必须设置的 - map.enableScrollWheelZoom(true); //开启鼠标滚轮缩放 - }) - + + map.centerAndZoom(new BMap.Point(104.067923463, 30.6799428454), 11); // 初始化地图,设置中心点坐标和地图级别 + //添加地图类型控件 + + // 继承API的BMap.Overlay + SquareOverlay.prototype = new BMap.Overlay(); + SquareOverlay.prototype.initialize = function (map) { + // 保存map对象实例 + this._map = map; + // 创建div元素,作为自定义覆盖物的容器 + var div = document.createElement("div"); + div.style.position = "absolute"; + // 可以根据参数设置元素外观 + div.style.width = this._length + "px"; + div.style.height = this._length + "px"; + div.style.background = this._color; + // 将div添加到覆盖物容器中 + map.getPanes().markerPane.appendChild(div); + // 保存div实例 + this._div = div; + // 需要将div元素作为方法的返回值,当调用该覆盖物的show、 + // hide方法,或者对覆盖物进行移除时,API都将操作此元素。 + return div; + } + SquareOverlay.prototype.draw = function(){ +// 根据地理坐标转换为像素坐标,并设置给容器 + var position = this._map.pointToOverlayPixel(this._center); + this._div.style.left = position.x - this._length / 2 + "px"; + this._div.style.top = position.y - this._length / 2 + "px"; +} +SquareOverlay.prototype.show = function(){ + if (this._div){ + this._div.style.display = ""; + } +} +// 实现隐藏方法 +SquareOverlay.prototype.hide = function(){ + if (this._div){ + this._div.style.display = "none"; + } +} + map.addControl(new BMap.MapTypeControl({ + mapTypes: [ + BMAP_NORMAL_MAP, + BMAP_HYBRID_MAP + ] + })); + + map.setCurrentCity("武汉"); // 设置地图显示的城市 此项是必须设置的 + map.enableScrollWheelZoom(true); //开启鼠标滚轮缩放 + }) + diff --git a/js/huaxia.js b/js/huaxia.js index f8a4b3b..b60f6e4 100644 --- a/js/huaxia.js +++ b/js/huaxia.js @@ -340,7 +340,7 @@ $(function(){ $(e.target).next().css('display','inline') console.log($(e.target).next().attr("class")); if ($(e.target).next().attr("class")!="upImg") { - console.log(123); + $(".uptoux").attr('src',$filePath); $(".ty_topimgtx").css("display","block")