不需要使用Toolbar。直接使用map的graphics类中的add方法。
/** * 在地图上画一个点 * * @param featureSet * @return */ function addPointsToMap() { console.debug("开始画点"); var myPoint = {"geometry":{"x":-104.4140625,"y":69.2578125, "spatialReference":{"wkid":4326}},"attributes":{"XCoord":-104.4140625, "YCoord":69.2578125,"Plant":"Mesa Mint"},"symbol":{"color":[255,0,0,128], "size":12,"angle":0,"xoffset":0,"yoffset":0,"type":"esriSMS", "style":"esriSMSSquare","outline":{"color":[0,0,0,255],"width":1, "type":"esriSLS","style":"esriSLSSolid"}}, "infoTemplate":{'title':'Vernal Pool Locations',"content":'Latitude: ${YCoord} <br/> Longitude: ${XCoord} <br/> Plant Name:${Plant}'}}; //根据一个JSON构建一个Graphic对象 var gra= new esri.Graphic(myPoint); //在当前地图上添加这个图像对象 myMap.graphics.add(gra); //删除这个图像 //myMap.graphics.remove(gra); }
api参考
http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/arcgis/help/jsapi_start.htm#jsapi/map.htm#toMap