!function(){ var infowindow, map, level = 12, center = {lng: 114.667049, lat: 38.224974}, features = [{type: "marker", name: "一然生物", desc: "地址:河北省石家庄市正定高新技术产业开发区邦秀东路16号
市场营销:0311-85178678
品牌策划:0311-85178700", color: "red", icon: "cir", offset: {x: -9, y: -31}, lnglat: {lng: 114.667049, lat: 38.224974}}]; 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}); loadfeatures(); map.on('complete', function(){ map.plugin(["amap.scale"], function(){ map.addcontrol(new amap.scale); }); }) }();