Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

How would you go about "selecting/hightlighting a feature" in the map control when a user clicks on a point in the map - all via ADF Javascript. I know it can be done server side with a selection graphics layer etc, just wondering if it can be done client side.

Cheers

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

Below I have put the code that I have used to display a black crosshair over a point feature in a map. It was quite simple in the end, but the overall implementation is a bit more involved and beyond the scope of this answer - but in essence -

  1. The user clicks on the map and I capture the coordinates.
  2. Coordinates are sent to webservice by XmlHttpRequest and a spatial filter is conducted.
  3. XML recieved from webservice after a successful spatial filter with results is found.
  4. The REAL x and y coordinates are passed back too from the spatial filter.
  5. These real x and y coordinates are used to place the graphic on the map - so it will only show if a successful query has been made - if not the graphic will never show - which is pretty much an emulation of the a select funcitonality.

    //you must use a unique ID each time you create a graphic
    //this is incremented at the end of the drawGraphic function.
    var graphicCount = 0; 
    var newPoint = new ESRI.ADF.Geometries.Point(456465, 354141);
    drawGraphic(newPoint);
    

    function drawGraphic(point) {
        //I am using a png graphic file here to mark a point in a kind of crosshair
        //24x24 pixels big and it looks pretty cool - make sure you have the background
        //transparent or else you won't be able to see underneath the graphic.

        var symbol = new ESRI.ADF.Graphics.MarkerSymbol("blacktarget.png", 12, 12, "");
        var coords = point.toString("<br>", ",");
        var attributes = { "ID": graphicCount, "featureCoordinates": coords };

        graphicFeature = $create(ESRI.ADF.Graphics.GraphicFeature, { "id": graphicCount.toString(), "geometry": point, "symbol": symbol, "attributes": attributes});
        map.addGraphic(graphicFeature);
        graphicCount++;
        }
share|improve this answer
add comment

As far as I understand your question, client is not aware of points, so there has to be a server interaction to achieve this.

share|improve this answer
    
sorry - had to mark this down as it strictly isn't true. Nothing personal of course... –  Vidar Aug 11 '10 at 16:31
    
I must have expressed my self rather poorly as your example above does exactly what I wanted to express. As the client is not aware of points, it has to ask the server whether there is a point where the user clicked (hint: the XmlhttpRequest). This is the server interaction I was referring too. So I don't have any issue marking my answer down for being too high level, inaccurate or such, but my any means it is not wrong. –  GuillaumeC Aug 12 '10 at 6:34
    
I agree - the client is not literally aware of points as it is just an image - so this has to be inferred by the server and passed back to the client. –  Vidar Aug 12 '10 at 8:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.