首页 文章 精选 留言 我的

精选列表

搜索[API接口],共10000篇文章
优秀的个人博客,低调大师

ArcGIS API for JavaScript 标注错位问题解决思路

项目需求:完成对点的符号化显示,并将点的某些信息显示在点符号的旁边。 设计 调研开始,展示数据前端一般用GraphicsLayer,再结合Graphic,PictureMarkerSymbol与TextSymbol就可以完成此工作。直接上代码 jidianjing_graphicsLayer: null, jidianjing_text_featureLayer: null, ... this.graphicsLayer = new GraphicsLayer({ id: "graphicsLayer", elevationInfo: { mode: "relative-to-ground", offset: 3 } }); ... view.map.add(this.graphicsLayer); ... let jidianjing_graphics = []; // 处理Graphics $.each(result, function (i, item) { item.widgetModule = 'jidianjingWidgetModule_click'; var stcd = item.STCD; var stnm = item.STNM; let tempPoint = new Point({ type: "point", x: item.LGTD, y: item.LTTD }); let normalsymbol = { type: "picture-marker", url: 'img/menu/081.png', width: "18px", height: "18px" }; if (!StringUtil.isNull(item.WARN_NAME)) { normalsymbol = { type: "picture-marker", url: 'img/menu/083.png', width: "28px", height: "28px" }; } else if (!StringUtil.isNull(item.LL)) { normalsymbol = { type: "picture-marker", url: 'img/menu/082.png', width: "28px", height: "28px" }; } let tempPop = new PopupTemplate({ title: '机电井:' + stnm, content: _self.setjidianjingContentInfo }); let tempGraphic = new Graphic({ geometry: tempPoint, attributes: item, symbol: normalsymbol, popupTemplate: tempPop }); let textGraphic = new Graphic({ geometry: tempPoint, symbol: new TextSymbol({ color: "#FFF", backgroundColor: new Color('red'), borderLineColor: new Color("#fff"), borderLineSize: 2, haloColor: "black", haloSize: "1px", text: '水位:12 水温:11', font: { size: 8, family: "sans-serif" } }) }); _self.jidianjing_graphicsLayer.add(tempGraphic); _self.jidianjing_text_graphicsLayer.add(textGraphic); ... 效果 说明gif图太大,aliyun拒绝了我的上传,所以只能用文字描述;在小比例尺下,符号标注和文字标注之间的距离较小,看着效果还可以,但是有会出现标注覆盖文字或者文字覆盖标注;随着比例尺的放大,符号和标注之间的距离会增大,如第二张图所示。但是拿给项目经理看的时候,不要这种效果,距离和标注与符号之间的距离不能变。so...改改改 新思路-构造FeatureLayer 查看了官网好多例子,发现只有FeatureLayer的标注和符号之间的距离是边的,因为我们拿到的数据是点数据,所以我们可以构造组成FeatureLayer的source,其实就对应ags里的Graphics;还有一个标注LabelClass,这个类就是用来显示标注的。so...又开干了。 jidianjing_featureLayer: null, ... let tempGraphics = []; // 处理Graphics $.each(result, function (i, item) { item.widgetModule = 'jidianjingWidgetModule_click'; var stcd = item.STCD; var stnm = item.STNM; let tempPoint = new Point({ type: "point", x: item.LGTD, y: item.LTTD }); let normalsymbol = { type: "picture-marker", url: 'img/menu/081.png', width: "18px", height: "18px" }; if (!StringUtil.isNull(item.WARN_NAME)) { normalsymbol = { type: "picture-marker", url: 'img/menu/083.png', width: "28px", height: "28px" }; } else if (!StringUtil.isNull(item.LL)) { normalsymbol = { type: "picture-marker", url: 'img/menu/082.png', width: "28px", height: "28px" }; } let tempPop = new PopupTemplate({ title: '机电井:' + stnm, content: _self.setjidianjingContentInfo }); let tempGraphic = new Graphic({ geometry: tempPoint, attributes: item, symbol: normalsymbol, popupTemplate: tempPop }); let textGraphic = new Graphic({ geometry: tempPoint, symbol: new TextSymbol({ color: "#FFF", backgroundColor: new Color('red'), borderLineColor: new Color("#fff"), borderLineSize: 2, haloColor: "black", haloSize: "1px", text: '水位:12 水温:11', font: { size: 8, family: "sans-serif" } }) }); tempGraphics.push(tempGraphic); ... // popup let tempPop = new PopupTemplate({ title: '机电井:' + '{STNM}', content: _self.setjidianjingContentInfo }); // 标注 var labelClass = new LabelClass({ minScale: 20000, symbol: { type: "label-3d", symbolLayers: [{ type: "text", material: { color: "white" }, size: 10, halo: { color: [0, 0, 0, 0.8], size: 0.5 } }], verticalOffset:{ minWorldLength: 20, } }, labelPlacement: "above-center", labelExpression: "水位:[STTP], 水温:[STCD]" // labelExpressionInfo: { // expression: "$feature.STNM" // } }); // 构建feetureLayer并实现标注 this.jidianjing_text_featureLayer = new FeatureLayer({ id: 'jidianjing_featureLayer', fields: [{ name: "STCD", alias: "STCD", type: "oid" }, { name: "LGTD", alias: "LGTD", type: "string" }, { name: "LTTD", alias: "LTTD", type: "string" }, { name: "STCD", alias: "STCD", type: "string" }, { name: "STNM", alias: "STNM", type: "string" }, { name: "STTP", alias: "STTP", type: "string" }, { name: "widgetModule", alias: "widgetModule", type: "string" }], objectIdField: "STCD", geometryType: "point", spatialReference: { wkid: 4326 }, source: tempGraphics, // an array of graphics with geometry and attributes // popupTemplate and symbol are not required in each graphic // since those are handled with the popupTemplate and // renderer properties of the layer popupTemplate: tempPop, // renderer: iconSymbolRenderer, maxScale: 0, minScale: 0, labelsVisible: true, labelingInfo: [labelClass] }); view.map.add(this.jidianjing_text_featureLayer); 效果 说明 可以在上面两张图中看到,标注和符号的位置一直都是固定的,并没有随着距离的变化而变化;这时候拿给项目经理,就这个效果还算满意。 总结 符号和标注之间的距离在GraphicsLayer和FeatureLayer中的表现是不一样的,所以要根据合适的场景进行选择取舍。另外,GraphicsLayer和FeatureLayer标注换行不能实现,对GraphicsLayer可以采用加多个TextSymbol的GraphicsLayer,设置GraphicsLayer相对地面的高度就可以实现,但是距离永远是个问题,在此给一些朋友一些提醒。

优秀的个人博客,低调大师

使用 ES decorators 构建一致性 API

![pic] 重用和一致性是程序设计中经久不衰的两个课题。在最新的 ES Proposal 中,「decorators 语法」为此带来了一定的便利,并且,很适合应用于大型的类库中。 装饰模式 提到 decorator 大家都不会陌生,即「装饰模式」—— 我们可以在「不侵入原有代码」的情况下,为代码增加一些「额外的功能」。 所谓「额外的功能」一般都比较独立,不和原有逻辑耦合,只是做一层包装。你也可以把它看成「包装模式」。形如: // 旧方法 function func() {} // 包装后的新方法 function funcWrapped() { // 有的没的 doSomethingBefore(); // 旧方法的过程本身并不变化 func(); // 这啊那的 doSomethingAfter

优秀的个人博客,低调大师

Android2.2 API 中文文档系列(6) —— ImageView

正文 一、结构 java.lang.Object android.view.View android.widget.ImageView 已知直接子类: ImageButton, QuickContactBadge 已知间接子类: ZoomButton 二、类概述 显示任意图像,例如图标。ImageView类可以加载各种来源的图片(如资源或图片库),需要计算图像的尺寸,比便它可以在其他布局中使用,并提供例如缩放和着色(渲染)各种显示选项。 三、XML属性 属性名称 描述 android:adjustViewBounds 是否保持宽高比。需要与maxWidth、MaxHeight一起使用,否则单独使用没有效果。 android:cropToPadding 是否截取指定区域用空白代替。单独设置无效果,需要与scrollY一起使用,效果如下,实现代码见代码部分: android:maxHeight 设置View的最大高度,单独使用无效,需要与setAdjustViewBounds一起使用。如果想设置图片固定大小,又想保持图片宽高比,需要如下设置: 1)设置setAdjustViewBounds为true; 2)设置maxWidth、MaxHeight; 3)设置设置layout_width和layout_height为wrap_content。 android:maxWidth 设置View的最大宽度。同上。 android:scaleType 设置图片的填充方式。 matrix 0 用矩阵来绘图 fitXY 1 拉伸图片(不按比例)以填充View的宽高 layout_ height :30px layout_ width :120px fitStart 2 按比例拉伸图片,拉伸后图片的高度为View的高度,且显示在View的左边 fitCenter 3 按比例拉伸图片,拉伸后图片的高度为View的高度,且显示在View的中间 fitEnd 4 按比例拉伸图片,拉伸后图片的高度为View的高度,且显示在View的右边 center 5 按原图大小显示图片,但图片宽高大于View的宽高时,截图图片中间部分显示 layout_ height :60px layout_ width :80px padding :10px centerCrop 6 按比例放大原图直至等于某边View的宽高显示。 centerInside 7 当原图宽高或等于View的宽高时,按原图大小居中显示;反之将原图缩放至View的宽高居中显示。 android:src 设置View的drawable(如图片,也可以是颜色,但是需要指定View的大小) android:tint 将图片渲染成指定的颜色。见下图: 左边为原图,右边为设置后的效果,见后面代码。 四、代码 4.1 android:tint < ImageView android:background ="@android:color/white" android:src ="@drawable/btn_mode_switch_bg" android:layout_width ="wrap_content" android:layout_height ="wrap_content" ></ ImageView > < ImageView android:layout_marginLeft ="5dp" android:background ="@android:color/white" android:tint ="#ffff00" android:src ="@drawable/btn_mode_switch_bg" android:layout_width ="wrap_content" android:layout_height ="wrap_content" ></ ImageView > 4.2 android:cropToPadding < ImageView android:background ="@android:color/white" android:scrollY ="-10px" android:cropToPadding ="true" android:src ="@drawable/btn_mode_switch_bg" android:layout_width ="wrap_content" android:layout_height ="wrap_content" ></ ImageView > < ImageView android:background ="@android:color/white" android:scrollY ="10px" android:cropToPadding ="true" android:src ="@drawable/btn_mode_switch_bg" android:layout_width ="wrap_content" android:layout_height ="wrap_content" ></ ImageView > < ImageView android:paddingTop ="10px" android:background ="@android:color/white" android:scrollY ="10px" android:cropToPadding ="true" android:src ="@drawable/btn_mode_switch_bg" android:layout_width ="wrap_content" android:layout_height ="wrap_content" ></ ImageView > < ImageView android:paddingTop ="10px" android:background ="@android:color/white" android:scrollY ="10px" android:cropToPadding ="false" android:src ="@drawable/btn_mode_switch_bg" android:layout_width ="wrap_content" android:layout_height ="wrap_content" ></ ImageView > 本文转自over140 51CTO博客,原文链接:http://blog.51cto.com/over140/582712,如需转载请自行联系原作者

优秀的个人博客,低调大师

Android2.2 API 中文文档系列(2) —— EditText

正文 一、结构 java.lang.Object android.view.View android.widget.TextView android.widget.EditText 已知直接子类: AutoCompleteTextView, ExtractEditText 已知间接子类: MultiAutoCompleteTextView 二、xml属性 属性名称 描述 android:autoLink 设置是否当文本为URL链接/email/电话号码/map时,文本显示为可点击的链接。可选值(none/web/email/phone/map/all)。这里只有在同时设置text时才自动识别链接,后来输入的无法自动识别。 android:autoText 自动拼写帮助。这里单独设置是没有效果的,可能需要其他输入法辅助才行,效果参见视频。 android:bufferType 指定getText()方式取得的文本类别。选项editable 类似于StringBuilder可追加字符, 也就是说getText后可调用append方法设置文本内容。spannable 则可在给定的字符区域使用样式,参见这里1、这里2。 android:capitalize 设置英文字母大写类型。设置如下值:sentences仅第一个字母大写;words每一个单词首字母大小,用空格区分单词;characters每一个英文字母都大写。在模拟器上用PC键盘直接输入可以出效果,但是用软键盘无效果。 android:cursorVisible 设定光标为显示/隐藏,默认显示。如果设置false,即使选中了也不显示光标栏。 android:digits 设置允许输入哪些字符。如“1234567890.+-*/%\n()” android:drawableTop 在text的正上方输出一个drawable。在EditView中的效果比较搞笑:,居然在文本框里,而且删不了。 android:drawableBottom 在text的下方输出一个drawable,如图片。如果指定一个颜色的话会把text的背景设为该颜色,并且同时和background使用时覆盖后者。 android:drawableLeft 在text的左边输出一个drawable(如图片)。 android:drawablePadding 设置text与drawable(图片)的间隔,与drawableLeft、drawableRight、drawableTop、drawableBottom一起使用,可设置为负数,单独使用没有效果。 android:drawableRight 在text的右边输出一个drawable,如图片。 android:editable 设置是否可编辑。仍然可以获取光标,但是无法输入。 android:editorExtras 指定特定输入法的扩展,如“com.mydomain.im.SOME_FIELD”。源码跟踪至EditorInfo.extras,暂无相关实现代码。 android:ellipsize 设置当文字过长时,该控件该如何显示。有如下值设置:”start”—–省略号显示在开头;”end”——省略号显示在结尾;”middle”—-省略号显示在中间;”marquee” ——以跑马灯的方式显示(动画横向移动) android:freezesText 设置保存文本的内容以及光标的位置。参见:这里。 android:gravity 设置文本位置,如设置成“center”,文本将居中显示。 android:hint Text为空时显示的文字提示信息,可通过textColorHint设置提示信息的颜色。 android:imeOptions 设置软键盘的Enter键。有如下值可设置:normal,actionUnspecified,actionNone,actionGo ,actionSearch,actionSend,actionNext,actionDone ,flagNoExtractUi,flagNoAccessoryAction,flagNoEnterAction。可用’|’设置多个。这里仅设置显示图标之用,参见文章末尾例子。 android:imeActionId 设置IME动作ID,在onEditorAction中捕获判断进行逻辑操作。 android:imeActionLabel 设置IME动作标签。但是不能保证一定会使用,猜想在输入法扩展的时候应该有用。 android:includeFontPadding 设置文本是否包含顶部和底部额外空白,默认为true。 android:inputMethod 为文本指定输入法,需要完全限定名(完整的包名)。例如:com.google.android.inputmethod.pinyin,但是这里报错找不到。关于自定义输入法参见这里。 android:inputType 设置文本的类型,用于帮助输入法显示合适的键盘类型。有如下值设置:none、text、textCapCharacters字母大小、textCapWords单词首字母大小、textCapSentences仅第一个字母大小、textAutoCorrect、textAutoComplete自动完成、textMultiLine多行输入、textImeMultiLine输入法多行(如果支持)、textNoSuggestions不提示、textEmailAddress电子邮件地址、textEmailSubject邮件主题、textShortMessage短信息(会多一个表情按钮出来,点开如下图: )、textLongMessage长讯息?、textPersonName人名、textPostalAddress地址、textPassword密码、textVisiblePassword可见密码、textWebEditText作为网页表单的文本、textFilte文本筛选过滤、textPhonetic拼音输入、numberSigned有符号数字格式、numberDecimal可带小数点的浮点格式、phone电话号码、datetime时间日期、date日期、time时间。部分参考这里。 android:marqueeRepeatLimit 在ellipsize指定marquee的情况下,设置重复滚动的次数,当设置为marquee_forever时表示无限次。 android:ems 设置TextView的宽度为N个字符的宽度。参见TextView中此属性的截图。 android:maxEms 设置TextView的宽度为最长为N个字符的宽度。与ems同时使用时覆盖ems选项。 android:minEms 设置TextView的宽度为最短为N个字符的宽度。与ems同时使用时覆盖ems选项。 android:maxLength 限制输入字符数。如设置为5,那么仅可以输入5个汉字/数字/英文字母。 android:lines 设置文本的行数,设置两行就显示两行,即使第二行没有数据。 android:maxLines 设置文本的最大显示行数,与width或者layout_width结合使用,超出部分自动换行,超出行数将不显示。 android:minLines 设置文本的最小行数,与lines类似。 android:linksClickable 设置链接是否点击连接,即使设置了autoLink。 android:lineSpacingExtra 设置行间距。 android:lineSpacingMultiplier 设置行间距的倍数。如”1.2” android:numeric 如果被设置,该TextView有一个数字输入法。有如下值设置:integer正整数、signed带符号整数、decimal带小数点浮点数。 android:password 以小点”.”显示文本 android:phoneNumber 设置为电话号码的输入方式。 android:privateImeOptions 提供额外的输入法选项(字符串格式)。依据输入法而决定是否提供,如这里所见。自定义输入法继承 InputMethodService。这篇文章也许有帮助。 android:scrollHorizontally 设置文本超出TextView的宽度的情况下,是否出现横拉条。 android:selectAllOnFocus 如果文本是可选择的,让他获取焦点而不是将光标移动为文本的开始位置或者末尾位置。TextView中设置后无效果。 android:shadowColor 指定文本阴影的颜色,需要与shadowRadius一起使用。参见TextView中此属性的截图。 android:shadowDx 设置阴影横向坐标开始位置。 android:shadowDy 设置阴影纵向坐标开始位置。 android:shadowRadius 设置阴影的半径。设置为0.1就变成字体的颜色了,一般设置为3.0的效果比较好。 android:singleLine 设置单行显示。如果和layout_width一起使用,当文本不能全部显示时,后面用“…”来表示。如android:text="test_ singleLine " android:singleLine="true" android:layout_width="20dp"将只显示“t…”。如果不设置singleLine或者设置为false,文本将自动换行 android:text 设置显示文本. android:textAppearance 设置文字外观。如“?android:attr/textAppearanceLargeInverse ”这里引用的是系统自带的一个外观,?表示系统是否有这种外观,否则使用默认的外观。可设置的值如下:textAppearanceButton/textAppearanceInverse/textAppearanceLarge/textAppearanceLargeInverse/textAppearanceMedium/textAppearanceMediumInverse/textAppearanceSmall/textAppearanceSmallInverse android:textColor 设置文本颜色 android:textColorHighlight 被选中文字的底色,默认为蓝色 android:textColorHint 设置提示信息文字的颜色,默认为灰色。与hint一起使用。 android:textColorLink 文字链接的颜色. android:textScaleX 设置文字之间间隔,默认为1.0f。参见TextView的截图。 android:textSize 设置文字大小,推荐度量单位”sp”,如”15sp” android:textStyle 设置字形[bold(粗体) 0, italic(斜体) 1, bolditalic(又粗又斜) 2]可以设置一个或多个,用“|”隔开 android:typeface 设置文本字体,必须是以下常量值之一:normal 0, sans 1, serif 2, monospace(等宽字体) 3] android:height 设置文本区域的高度,支持度量单位:px(像素)/dp/sp/in/mm(毫米) android:maxHeight 设置文本区域的最大高度 android:minHeight 设置文本区域的最小高度 android:width 设置文本区域的宽度,支持度量单位:px(像素)/dp/sp/in/mm(毫米),与layout_width的区别看这里。 android:maxWidth 设置文本区域的最大宽度 android:minWidth 设置文本区域的最小宽度 补充说明: a). 由于是继承自TextView,所以属性是一样的,但是这里重点补充了输入法相关的属性说明和研究,部分注释也做了相应的调整。 b). Word格式下载 http://download.csdn.net/source/2664164 三、例子 3.1 <!--[endif]-->android:imeOptions例子 < EditText android:id ="@+id/txtTest" android:imeOptions ="actionGo" android:layout_width ="100dp" android:layout_height ="wrap_content" ></ EditText > ((EditText)findViewById(R.id.txtTest)).setOnEditorActionListener( new TextView.OnEditorActionListener(){ @Override public boolean onEditorAction(TextViewv, int actionId, KeyEventevent){ if (actionId == EditorInfo.IME_ACTION_GO){ Toast.makeText(TestActivity. this , " 你点了Go! " ,Toast.LENGTH_SHORT).show(); } return false ; } }); 本文转自over140 51CTO博客,原文链接:http://blog.51cto.com/over140/582733,如需转载请自行联系原作者

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册
修改密码
忘记密码