Arcgis for Javascript中给出坐标点定位
Arcgis for Javascript中给出坐标点定位
龙马行空 发表于3年前
Arcgis for Javascript中给出坐标点定位
  • 发表于 3年前
  • 阅读 1436
  • 收藏 1
  • 点赞 0
  • 评论 0

华为云·免费上云实践>>>   

摘要: 坐标点定位

1、引用gis的css样式和js文件

@*gis的css*@
<link href="http://11.101.9.53/arcgis_js_v39_sdk/arcgis_js_api/library/3.9/3.9/js/dojo/dijit/themes/claro/claro.css" rel="stylesheet" />
<link href="http://11.101.9.53/arcgis_js_v39_sdk/arcgis_js_api/library/3.9/3.9/js/esri/css/esri.css" rel="stylesheet" />

@*gis的js*@
<script src="http://11.101.9.53/arcgis_js_v39_sdk/arcgis_js_api/library/3.9/3.9/init.js"></script>
<script src="/Static/js/gis.js"></script>


2、

var GISSERVERURL = "http://11.101.9.53:6080/";// 定义地图的服务器地址
var map;// 定义地图容器
var locationPoint;// 定义定位地图的方法

// 加载地图引用
require([
    "esri/SpatialReference",
    "esri/arcgis/utils", "esri/dijit/Print",
    "esri/tasks/PrintTemplate", "esri/config",
    "dojo/_base/array",
    "esri/map",
    "esri/layers/ArcGISTiledMapServiceLayer",
    "esri/layers/GraphicsLayer",
    "esri/dijit/HomeButton",
    "esri/toolbars/draw",
    "esri/toolbars/edit",
    "esri/graphic",
    "esri/symbols/PictureMarkerSymbol",
    "esri/symbols/SimpleMarkerSymbol",
    "esri/symbols/SimpleLineSymbol",
    "esri/symbols/SimpleFillSymbol",
    "esri/dijit/Scalebar",
    "esri/geometry/Extent",
    "esri/geometry/Geometry",
    "esri/geometry/Point",
    "esri/layers/FeatureLayer",
    "esri/layers/GraphicsLayer",
    "esri/layers/ArcGISDynamicMapServiceLayer",
    "esri/renderers/ClassBreaksRenderer",
    "esri/dijit/Popup",
    "esri/dijit/PopupTemplate",
    "esri/dijit/InfoWindow",
    "esri/tasks/QueryTask",
    "esri/tasks/query",
    "dijit/Menu",
    "dijit/MenuItem",
    "dijit/MenuSeparator",
    "dojo/_base/connect",
    "dojo/_base/event",
    "dojo/dom", "dojo/parser", "dojo/on", "dojo/_base/Color",
    //"agsjs/dijit/TOC",
    "dojo/fx",
    "dijit/layout/BorderContainer",
    "dijit/layout/ContentPane",
    "dojo/domReady!"
], function (
    SpatialReference,
    arcgisUtils, Print,
    PrintTemplate, esriConfig,
    arrayUtils,
    Map,
    ArcGISTiledMapServiceLayer,
    GraphicsLayer,
    HomeButton,
    Draw,
    Edit,
    Graphic,
    PictureMarkerSymbol,
    SimpleMarkerSymbol,
    SimpleLineSymbol,
    SimpleFillSymbol,
    Scalebar,
    Extent, Geometry, Point, FeatureLayer, GraphicsLayer, ArcGISDynamicMapServiceLayer, ClassBreaksRenderer,
    Popup, PopupTemplate, InfoWindow, QueryTask, Query, Menu, MenuItem, MenuSeparator,
    connect, event, dom, parser, on, color
) {

    // 初始化地图容器
    map = new Map("dituContent", {
        logo: false,
        slider: true,
        aotoResize: true
    });

    // 初始化地图
    var AdministrativeMapUrl = GISSERVERURL + "arcgis/rest/services/ThematicMaps/AdministrativeMap/MapServer";
    var AdministrativeMap = new ArcGISDynamicMapServiceLayer(AdministrativeMapUrl);

    // 地图容器加载地图
    map.addLayer(AdministrativeMap);
    var areaExtentInit = new Extent({ "xmin": 496842.59900993377, "ymin": 4545585.342776724, "xmax": 540778.3368816553, "ymax": 4569334.390274952, "spatialReference": { "wkid": 2387 } });
    map.setExtent(areaExtentInit);

    map.on("load", function () {
        // 地图定位事件。
        locationPoint = function (x, y) {
            // 动态图定义的显示范围
            var areaExtentInit = new Extent({ "xmin": 516564.5131023098, "ymin": 4554743.569218228, "xmax": 517937.5049108011, "ymax": 4555485.726952547, "spatialReference": { "wkid": 2387 } });
            map.setExtent(areaExtentInit);

            // 定义显示的水滴图标
            var markerSymbol = new SimpleMarkerSymbol();
            markerSymbol.setPath("M16,3.5c-4.142,0-7.5,3.358-7.5,7.5c0,4.143,7.5,18.121,7.5,18.121S23.5,15.143,23.5,11C23.5,6.858,20.143,3.5,16,3.5z M16,14.584c-1.979,0-3.584-1.604-3.584-3.584S14.021,7.416,16,7.416S19.584,9.021,19.584,11S17.979,14.584,16,14.584z");
            markerSymbol.setColor(new color([240, 3, 15, 1]));

            //定位点
            var point = new Point(x, y, new SpatialReference({ wkid: 2387 }));
            map.centerAt(point);

            //在地图上显示水点图标并定位
            var gra = new Graphic(point, markerSymbol);
            map.graphics.add(gra);
        };
    });
});


共有 人打赏支持
粉丝 371
博文 127
码字总数 94401
×
龙马行空
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: