caosong094542
我的安静不安静
采纳率0%
2015-12-23 07:42

利用arcgis api for javascript实现在地图上点的弹出(我的信息弹出不了)

2

<!DOCTYPE html>




Simple Map
<style>
  html, body, #map {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
  }
  body {
    background-color: #FFF;
    overflow: hidden;
    font-family: "Trebuchet MS";
  }
</style>
<script type="text/javascript" src="http://192.168.1.187:8080/arcgis_js_api/library/3.9/3.9/init.js"></script>

<script>
    var map, graphic1, pointlayer, myPoint1;

    require([
        "dojo/dom", "dojo/_base/array", "dojo/promise/all", "dojo/json",
        "esri/map", "esri/domUtils", "esri/graphic", "esri/graphicsUtils",
        "esri/geometry/Polygon", "esri/tasks/GeometryService", "esri/geometry/Point", "esri/tasks/Geoprocessor",
        "esri/tasks/FeatureSet", "esri/tasks/RelationParameters", "esri/symbols/PictureMarkerSymbol",
        "esri/Color", "esri/symbols/SimpleLineSymbol", "esri/SpatialReference",
        "esri/symbols/SimpleMarkerSymbol", "esri/symbols/SimpleFillSymbol",
        "esri/layers/GraphicsLayer", "esri/geometry/Extent", "esri/InfoTemplate", "dojo/domReady!"
    ], function (dom, array, all, JSON,
        Map, domUtils, Graphic, graphicsUtils,
        Polygon, GeometryService, Point, Geoprocessor,
        FeatureSet, RelationParameters, PictureMarkerSymbol,
        Color, SimpleLineSymbol, SpatialReference,
        SimpleMarkerSymbol, SimpleFillSymbol,
        GraphicsLayer, InfoTemplate
        ) {
        map = new Map("map", {
            basemap: "topo",
            center: [113.33, 36.33],
            zoom: 13
        });


        pointlayer = new GraphicsLayer();
        map.addLayer(pointlayer);

        var attributes = {
            "省份": "安徽",
            "录取率": 43.04,
            "未录取率": 56.96
        };
        myPoint1 = esri.geometry.geographicToWebMercator(new esri.geometry.Point
        (
        {
            "x": 113.33,
            "y": 36.33,
            "spatialReference": { "wkid": 4326 }
        }));

       var symbol = new esri.symbol.PictureMarkerSymbol('image/chaoren.png', 20, 20);

       var infoTemplate = new InfoTemplate("标题${省份}", "${省份}的录取率为${录取率},未录取率为${未录取率}");
        graphic1 = new esri.Graphic(myPoint1, symbol, attributes, infoTemplate);

        pointlayer.add(graphic1);

    });
</script>              




  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

相关推荐