理解ESRI API时出现问题
Trouble Understanding the ESRI API
我是ESRI Javascript API的新手。我不明白在有新图形的线上需要做什么。
var graphic = new esri.Graphic(geoPoint, symbol, attr, infoTemplate);
这是我连接在一起的许多示例代码中的最后一个。有人能提出一个解决方案吗。谢谢你的帮助。下面是整个功能。如果你需要完整的剧本,请告诉我。
function onGeocodesuccess(results)
{
console.log(results);
var geoPoint = new esri.geometry.Point(results.utm_x, results.utm_y, map.spatialReference);
var symbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_CIRCLE, 15, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0,0,255]), 2), new dojo.Color([0,0,255]));
var infoTemplate = new esri.InfoTemplate("Attributes", "${*}");
var graphic = new esri.Graphic(geoPoint, symbol, attr, infoTemplate);
map.graphics.add(graphic);
map.infoWindow.setTitle(graphic.getTitle());
map.infoWindow.setContent(graphic.getContent());
var screenPnt = map.toScreen(geoPoint);
map.infoWindow.show(screenPnt,map.getInfoWindowAnchor(screenPnt));
}
"attr"变量不需要任何东西,因为它是可选的。在上面的例子中,我会删除"attr",因为它没有在函数中定义或需要。
var graphic = new esri.Graphic(geoPoint, symbol, attr, infoTemplate);
ESRI有图形类的下降文档。
attr是一个具有字段键、字段名和字段值的对象,它通常由服务器返回的特性填充。当你创建一个新的图形时,这是一个可选参数,如前所述,你可以在创建新图形时去掉这个参数,在你的情况下,这将是:
function onGeocodesuccess(results) {
console.log(results);
var geoPoint = new esri.geometry.Point(results.utm_x, results.utm_y, map.spatialReference);
var symbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_CIRCLE, 15, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0,0,255]), 2), new dojo.Color([0,0,255]));
var infoTemplate = new esri.InfoTemplate("Attributes", "${*}");
var graphic = new esri.Graphic(geoPoint, symbol);
map.graphics.add(graphic);
map.infoWindow.setTitle(graphic.getTitle());
map.infoWindow.setContent(graphic.getContent());
var screenPnt = map.toScreen(geoPoint);
map.infoWindow.show(screenPnt,map.getInfoWindowAnchor(screenPnt));
}
相关文章:
- 在指令控制器中使用$attrs时出现问题
- 将PHP变量传递给jQuery时遇到问题
- Canvas Html5绘图应用程序,移动画布会导致重大问题
- 参数变量出现ngTable指令问题
- 剑道网格jQuery动画()问题
- 我的jQuery插件参数没有正确启动,遇到了问题
- Phonegap-(安卓/iphone)多个图像的图像库出现问题
- TableExport jquery插件:文件名和扩展名问题
- esri javascript异步打印
- JavaScript Pub/Sub属性访问问题
- JavaScript异步问题
- 如何解决Yii中的页面刷新问题
- Safari(Mac OS)上的jQuery平滑滚动问题
- jqGrid树网格问题
- 使用正则表达式评估电子邮件地址时出现性能问题
- 如何消除代码中的未定义和其他问题
- JavaScript代码问题:我正在将对象转换为数组
- 三星智能电视应用程序;Brightcove示例应用程序远程控制问题
- 理解ESRI API时出现问题
- ESRI'中的toolbar.dectivate()出现问题;API