Version 3.4 map's infoWindow coords, anchor and fixed anchor are undefined

1124
3
Jump to solution
05-02-2013 08:40 AM
AaronConnolly
Occasional Contributor
Take the following code and notice that in the browser's javascript console that the map info window's coords, anchor and fixed anchor properites are 'undefined'. Why?

Am I using the info window incorrectly? Does this have anything to do with it not having a symbol associated with it? The docs don't make it at all clear what I might be doing wrong.

<!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>


**EDIT**

This is not associated with there being a symbol or a renderer on a graphics layer to which the info window points. I was able to reproduce this problem in a separate application that has both symbols and renderers. The map infoWindow's coords property is always undefined. What am I doing wrong?
0 Kudos
1 Solution

Accepted Solutions
KellyHutchins
Esri Frequent Contributor
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); 

View solution in original post

0 Kudos
3 Replies
KellyHutchins
Esri Frequent Contributor
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); 
0 Kudos
AaronConnolly
Occasional Contributor
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.
0 Kudos
AaronConnolly
Occasional Contributor
Thanks Kelly, that fixed the issue.


Quick follow up: Is the syntax:

var infoWindow = new esri.esri.dijit.InfoWindow({}, dojo.create("div", null, Map.Map.root));


... with two 'esri' namespaces in the constructor, 100% accurate? The documentation says that you should use only one:

https://developers.arcgis.com/en/javascript/jsapi/infowindow-amd.html

This code:

var infoWindow = new esri.dijit.InfoWindow({}, dojo.create("div", null, Map.Map.root));


... worked for us in production until very recently. The code now throws an error that says that this is not a valid constructor. Did something change? Your code (with two esri.esri name spaces) and the documentation (only one esri namespace) are in conflict.

Thanks,
- Aaron
0 Kudos