rdunfey

ArcGIS 10, JSAPI 2.0, FeatureLayer, How do I catch the OnMouseUp Event?

Discussion created by rdunfey on Jul 28, 2010
Latest reply on Jul 3, 2013 by KG22
Hi,

I'm trying to modify an ESRI sample:

http://resources.esri.com/help/webapi/javascript/arcgis/demos/featurelayer/fl_hover.html

I use the OnMouseOver event to hightlight the feature, then I want to use the onMouseUp or onClick to open a hyperlink (stored as a value in an attribuite field in a new window).  I can't get the OnMouseUp event to fire?  I understand that this should be inherited from the Graphics Layer class?

Any ideas appreciated,

Rob


      function init() {
        var startExtent = new esri.geometry.Extent(-160, -60, 170, 75, new esri.SpatialReference({wkid:4326}));
        //create map
        var map = new esri.Map("mapDiv",{extent:startExtent});
        dojo.connect(map, "onLoad", function() {
          //listen for when map.graphics onMouseOut event is fired and then clear the highlight graphic
          //and hide the info window
          dojo.connect(map.graphics, "onMouseOut", function(evt) {
            map.graphics.clear();
            map.infoWindow.hide();
          });
        });
        //create and add new layer
        var layer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer");
        map.addLayer(layer);

        var southCarolinaCounties = new esri.layers.FeatureLayer("http://myserver.com/ArcGIS/rest/services/Countries/FeatureServer/1", {
          mode: esri.layers.FeatureLayer.MODE_SNAPSHOT,
          outFields: ["CNTRY_NAME", "SITE_URL_1"]
        });
        southCarolinaCounties.setDefinitionExpression("1=1");

        var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,215,0,0.35]), 1),new dojo.Color([255,215,0,0.10]));
        southCarolinaCounties.setRenderer(new esri.renderer.SimpleRenderer(symbol));
        map.addLayer(southCarolinaCounties);

        var infoTemplate = new esri.InfoTemplate();
        infoTemplate.setTitle("${CNTRY_NAME}");
        infoTemplate.setContent("<b>2000 Population: </b>${SITE_URL_1}<br/>");
        map.infoWindow.resize(245,125);

        var highlightSymbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([205, 38, 38]), 3), new dojo.Color([255,215,0, 0.35]));
        //listen for when the onMouseOver event fires on the countiesGraphicsLayer
        //when fired, create a new graphic with the geometry from the event.graphic and add it to the maps graphics layer
        dojo.connect(southCarolinaCounties, "onMouseDown", function(evt) {

            //This alert isnt being fired???
            alert('hello');

            //Open New Window with URL from attribute field
            //window.open(evt.graphic.attributes.SITE_URL_1, "blank")

        });

        dojo.connect(southCarolinaCounties, "onMouseOver", function(evt) {
       
        //This all fires fine?
        map.graphics.clear();
        var highlightGraphic = new esri.Graphic(evt.graphic.geometry, highlightSymbol);
        map.graphics.add(highlightGraphic);

        });

Outcomes