var map, webmapId = "map id"; require([ "esri/map", "esri/arcgis/utils", "dojo/domReady!" ], function (Map, arcgisUtils) { arcgisUtils.createMap(webmapId, "mapDiv").then(function (response) { map = response.map; map.on("load", function(){ map.infoWindow.resize(250,100); }); var point = new esri.geometry.Point(8.7386350, 41.9192290); point = esri.geometry.geographicToWebMercator(point); var symbol = new esri.symbol.PictureMarkerSymbol("btb.png", 16, 16); var graphic = new esri.Graphic(point, symbol); var layer = new esri.layers.GraphicsLayer(); layer.add(graphic); map.addLayer(layer); dojo.connect(layer, "onClick", onClick); function onClick(evt) { map.infoWindow.setTitle("Test"); map.infoWindow.setContent( "test test test test" ); map.infoWindow.show(evt.screenPoint); } }); }); </script> </head> <body class="claro"> <div id="mapDiv"></div> </body> </html>
Solved! Go to Solution.
var map, webmapId = "123456"; require([ "esri/map", "esri/arcgis/utils", "esri/InfoTemplate", "esri/geometry/Point", "esri/geometry/webMercatorUtils", "esri/symbols/PictureMarkerSymbol", "esri/graphic", "esri/layers/GraphicsLayer", "dojo/domReady!" ], function( Map, arcgisUtils, InfoTemplate, Point, webMercatorUtils, PictureMarkerSymbol, Graphic, GraphicsLayer ) { arcgisUtils.createMap(webmapId, "mapDiv").then(function(response) { map = response.map; map.on("load", function() { map.infoWindow.resize(250, 100); }); var point = new Point(-75.16994, 40.00284); point = webMercatorUtils.geographicToWebMercator(point); var symbol = new PictureMarkerSymbol("btb.png", 16, 16); var attr = {"Xcoord":point.x,"Ycoord":point.y}; var infoTemplate = new InfoTemplate("Location","Latitude: ${Ycoord} <br/>Longitude: ${Xcoord}"); var graphic = new Graphic(point, symbol, attr, infoTemplate); var layer = new GraphicsLayer(); layer.add(graphic); map.addLayer(layer); }); });
var map, webmapId = "123456"; require([ "esri/map", "esri/arcgis/utils", "esri/InfoTemplate", "esri/geometry/Point", "esri/geometry/webMercatorUtils", "esri/symbols/PictureMarkerSymbol", "esri/graphic", "esri/layers/GraphicsLayer", "dojo/domReady!" ], function( Map, arcgisUtils, InfoTemplate, Point, webMercatorUtils, PictureMarkerSymbol, Graphic, GraphicsLayer ) { arcgisUtils.createMap(webmapId, "mapDiv").then(function(response) { map = response.map; map.on("load", function() { map.infoWindow.resize(250, 100); }); var point = new Point(-75.16994, 40.00284); point = webMercatorUtils.geographicToWebMercator(point); var symbol = new PictureMarkerSymbol("btb.png", 16, 16); var attr = {"Xcoord":point.x,"Ycoord":point.y}; var infoTemplate = new InfoTemplate("Location","Latitude: ${Ycoord} <br/>Longitude: ${Xcoord}"); var graphic = new Graphic(point, symbol, attr, infoTemplate); var layer = new GraphicsLayer(); layer.add(graphic); map.addLayer(layer); }); });