mike.zheng

I can invisible "point", but after zoom in/out, the point is shown again! Why?

Discussion created by mike.zheng on Jun 17, 2011
Latest reply on Jun 17, 2011 by agup-esristaff
My code like below:

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Untitled Page</title>
    <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.3/js/dojo/dijit/themes/tundra/tundra.css">
    <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.3/js/esri/dijit/css/Popup.css">
    <link rel="stylesheet" type="text/css" href="css/layout.css">  
<script type="text/javascript">
    var djConfig = {
        parseOnLoad: true
    };
</script>
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.3"></script>

<script type="text/javascript" src="javascript/layout.js"></script>

    <script type="text/javascript">
        dojo.require("dijit.dijit"); // optimize: load dijit layer
        dojo.require("dijit.layout.StackContainer");
        dojo.require("dijit.layout.BorderContainer");
        dojo.require("dijit.layout.ContentPane");
        dojo.require("esri.map");
        dojo.require("esri.layers.FeatureLayer");
        dojo.require("esri.dijit.Popup");

        dojo.require("esri.arcgis.utils");
        dojo.require("esri.dijit.Scalebar");
        dojo.require("esri.dijit.editing.Editor-all");
        dojo.require("esri.tasks.geometry");
        var gsvc = null;

        var map;
        var siteLayer;
        var resizeTimer;
        var identifyTask, identifyParams;
        var locationLayer, morningsideLayer;
        var webmap;

        function init() {

            //setup the map's initial extent
            var initExtent = new esri.geometry.Extent({ "xmin": -16075536.684978526, "ymin": 3886141.8596739126, "xmax": -5058820.67229557, "ymax": 9756505.631973889, "spatialReference": { "wkid": 102100} });
            var popup = new esri.dijit.Popup(null, dojo.create("div"));
            map = new esri.Map("map", {
                extent: initExtent,
                infoWindow: popup,
                showInfoWindowOnClick: false
            });
            dojo.place(popup.domNode, map.root);

            //Add the imagery layer to the map.
            var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer");
            map.addLayer(basemap);

            var content = "<b>${Comments}</b>";
            var infoTemplate = new esri.InfoTemplate("Census", content);
            siteLayer = new esri.layers.FeatureLayer("http://fc-wapps-trial/ArcGIS/rest/services/FirstCapitalRealtyForDemo/MapServer/0/", {
                mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
                outFields: ["*"],
                infoTemplate: infoTemplate
            });
            map.addLayer(siteLayer);

            dojo.connect(map, "onClick", function (evt) {
                map.infoWindow.hide();
            });

            dojo.connect(siteLayer, "onMouseOver", function (evt) {
                evt.graphic.attributes.Comments = "test";
                map.infoWindow.setFeatures([evt.graphic]);
                map.infoWindow.show(evt.mapPoint);
                map.infoWindow.resize(300, 150);
            });

            //resize the map when the browser resizes - view the 'Resizing and repositioning the map' section in
            dojo.connect(map, 'onLoad', function () {
                dojo.connect(dijit.byId('map'), 'resize', function () { //resize the map if the div is resized
                    clearTimeout(resizeTimer);
                    resizeTimer = setTimeout(function () {
                        map.resize();
                        map.reposition();
                    }, 500);
                });
            });
        }

        dojo.addOnLoad(init);

        function provinceChanged() {

            map.setExtent(new esri.geometry.Extent({ "xmin": -12449771.627754202, "ymin": 4911254.148340904, "xmax": -5904316.021639728, "ymax": 7846436.034490892, "spatialReference": { "wkid": 102100} }));

            var siteIDs = new Array();
            siteIDs[0] = "13001";
            siteIDs[1] = "10011";
            siteIDs[2] = "11252";
            dojo.forEach(siteLayer.graphics, function (graphic) {
                if (siteIDs.exists(graphic.attributes.SiteID)) {
                    graphic.visible = true;
                }
            });

            map.infoWindow.hide();
        }

        Array.prototype.exists = function (o) {
            for (var i = 0; i < this.length; i++)
                if (this[i] == o)
                    return true;
            return false;
        }

    </script>
   
</head>
<body class="tundra">
    <form id="form1" style="width:100%" runat="server">
        <div width="100%">
             <div id="map" style="width:100%; height:600px"></div>
        </div>
        <input type="button" onclick="provinceChanged()" value="hide some point" />
    </form>       
</body>
</html>

Outcomes