!function(){ var infowindow, map, level = 16, center = {lng: 117.889964, lat: 31.56334}, features = [{type: "marker", name: "安徽天意环保科技有限公司", desc: "厂址:安徽省合肥市巢湖市居巢经济开发区前进路
电话:0551-82188998,82188995
传真:0551-82188995
邮箱:info@tianyieptech.com", color: "red", icon: "cir", offset: {x: -9, y: -31}, lnglat: {lng: 117.889964, lat: 31.56334}}]; function loadfeatures(){ for(var feature, data, i = 0, len = features.length, j, jl, path; i < len; i++){ data = features[i]; switch(data.type){ case "marker": feature = new amap.marker({ map: map, position: new amap.lnglat(data.lnglat.lng, data.lnglat.lat), zindex: 3, extdata: data, offset: new amap.pixel(data.offset.x, data.offset.y), title: data.name, content: '
' }); break; case "polyline": for(j = 0, jl = data.lnglat.length, path = []; j < jl; j++){ path.push(new amap.lnglat(data.lnglat[j].lng, data.lnglat[j].lat)); } feature = new amap.polyline({ map: map, path: path, extdata: data, zindex: 2, strokeweight: data.strokeweight, strokecolor: data.strokecolor, strokeopacity: data.strokeopacity }); break; case "polygon": for(j = 0, jl = data.lnglat.length, path = []; j < jl; j++){ path.push(new amap.lnglat(data.lnglat[j].lng, data.lnglat[j].lat)); } feature = new amap.polygon({ map: map, path: path, extdata: data, zindex: 1, strokeweight: data.strokeweight, strokecolor: data.strokecolor, strokeopacity: data.strokeopacity, fillcolor: data.fillcolor, fillopacity: data.fillopacity }); break; default: feature = null; } if(feature){ amap.event.addlistener(feature, "click", mapfeatureclick); } } } function mapfeatureclick(e){ if(!infowindow){ infowindow = new amap.infowindow({automove: true}); } var extdata = e.target.getextdata(); infowindow.setcontent("
" + extdata.name + "
" + extdata.desc + "
"); infowindow.open(map, e.lnglat); } map = new amap.map("mapcontainer", {center: new amap.lnglat(center.lng, center.lat), level: level, scrollwheel: false}); loadfeatures(); map.on('complete', function(){ map.plugin(["amap.toolbar"], function(){ map.addcontrol(new amap.toolbar); }); }) }();