<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" /> <!--The viewport meta tag is used to improve the presentation and behavior of the samples on iOS devices--> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/> <title>Info Window Tests</title> <!-- ESRI Required --> <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.4/js/esri/css/esri.css" /> <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.4/js/dojo/dijit/themes/tundra/tundra.css"/> <script type="text/javascript">var dojoConfig = { parseOnLoad: true };</script> <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/3.4"></script> <script type="text/javascript"> dojo.require("esri.map"); var map; var streetsUrl = "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"; function init() { var initExtent = new esri.geometry.Extent({ "xmin": -13646149, "ymin": 3606604, "xmax": -12393805, "ymax": 4232776, "spatialReference": { "wkid": 102100} }); map = new esri.Map("map", { extent: initExtent }); var layer0 = new esri.layers.ArcGISTiledMapServiceLayer(streetsUrl, { "id": "Streets", "opacity": 1.0, "visible": true }); var BASE_MAP_ARRAY = [layer0]; map.addLayers(BASE_MAP_ARRAY); dojo.connect(map, "onLoad", function (map) { map.infoWindow.resize(250, 100); }); dojo.connect(map, "onClick", addPoint); dojo.connect(map.infoWindow, "onShow", onInfoWindowShown); } function addPoint(evt) { map.infoWindow.setTitle("Coordinates"); //Need to convert the coordinates from the map's spatial reference (web mercator) to geographic to display lat/lon values var geoPt = esri.geometry.webMercatorToGeographic(evt.mapPoint); map.infoWindow.setContent("lat/lon : " + geoPt.y.toFixed(2) + ", " + geoPt.x.toFixed(2) + "<br />screen x/y : " + evt.screenPoint.x + ", " + evt.screenPoint.y); map.infoWindow.show(evt.mapPoint, map.getInfoWindowAnchor(evt.screenPoint)); } function onInfoWindowShown() { logMessage("info window coords: " + map.infoWindow.coords); logMessage("info window anchor: " + map.infoWindow.anchor); logMessage("info window fixed anchor: " + map.infoWindow.fixedAnchor); logMessage("info window isShowing: " + map.infoWindow.isShowing); } function logMessage(message) { // Check for a console object var console = window['console']; // Log a message if a log property is available //--------------------------------------------- if (console && console.log) { console.log(message); } } dojo.ready(init); </script> </head> <body class="claro"> <div id="map" style="width:1024px; height:512px; border:1px solid #000;"></div> </body> </html>
Solved! Go to Solution.
map = new esri.Map("map", { extent: initExtent }); var infoWindow = new esri.esri.dijit.InfoWindow({}, dojo.create("div", null, map.root)); infoWindow.startup(); map.setInfoWindow(infoWindow);
map = new esri.Map("map", { extent: initExtent }); var infoWindow = new esri.esri.dijit.InfoWindow({}, dojo.create("div", null, map.root)); infoWindow.startup(); map.setInfoWindow(infoWindow);
At 3.4 we switched the map's default info window from esri.dijit.InfoWindow to esri.dijit.Popup and the Popup doesn't have the coords, fixedAnchor and anchor properties. We need to update our documentation to reflect this update and will do so for the next release.
If you'd like to switch back to the InfoWindow you can use the following code to switch back to the 'old' info window which does have the properties you are looking for.map = new esri.Map("map", { extent: initExtent }); var infoWindow = new esri.esri.dijit.InfoWindow({}, dojo.create("div", null, map.root)); infoWindow.startup(); map.setInfoWindow(infoWindow);
Thanks Kelly, that fixed the issue.
var infoWindow = new esri.esri.dijit.InfoWindow({}, dojo.create("div", null, Map.Map.root));
var infoWindow = new esri.dijit.InfoWindow({}, dojo.create("div", null, Map.Map.root));