Select to view content in your preferred language

Interactive webmap

4494
7
Jump to solution
08-13-2015 11:16 AM
GéomatiqueVRN
Occasional Contributor

I would like to know how to make a layer, representing administrative limits, interactive with hover-clickable polygones. The layer is included in a mapservice used to publish a webmap. If the answer is yes, is there an easy method I can follow to achieve this task ? Here is an example of what I want http://developers.arcgis.com/javascript/samples/query_hover/ ? But instead of the pop-up window, the user click will trigger a zoom-in to the urban area of the polygone.

Thanks!

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
GéomatiqueVRN
Occasional Contributor

There are two  type of config files that we have access to and that we can modify. An index.html which controls the html page and a Desktop.json.js which is in charge of all the component (modules) of the viewer for html5. The same thing applies for the Tablet and Handheld platforms (Tablet.html, Tablet.json.js, Handhel.html and Handheld.json.js). There are also Style files (css) for each platform.

All these config files can be edited in a text editor. I will try to modify the codebase of the .html config file for each platform by adding the lines of codes above.

In regard to Geocortex, it's an interesting application. Here is their website Geocortex - Accomplish even more with your investment in the ArcGIS platform - Web GIS Mapping Softw...  if you are interested to  take

a look at it.

Thank you again for your time and have a nice weekend!

Badre

View solution in original post

0 Kudos
7 Replies
ChrisSmith7
Honored Contributor

Are you familiar enough with the ArcGIS JSAPI that if we provide a sample, you can implement? Or, do you need information on how to use the ArcGIS JSAPI, creating and publishing map services, etc. in addition to a sample?

0 Kudos
GéomatiqueVRN
Occasional Contributor

Hi Chris,

No, I'm not familiar with the ArcGIS JSAPI. Actually, we are using Geocortex Essentiels 4.3.2 ( viewer for HTML5  2.4 version) to publish a webmap.The index.html config file of our site loads many apis and  the 3.13 version of the arcgis JSAPI is among them:

<script type="text/javascript" src="//js.arcgis.com/3.13/init.js"></script>

I would  be grateful if you can explain to me how to make use of this arcgis jsapi that is already there.The layer that we want to make dynamic is the topmost one, is visible at full scale and is no longer visible when we zoom-in.

Thanks

0 Kudos
ChrisSmith7
Honored Contributor

I am not familiar with Geocortex - I'd need to know more information on how to help you with your current set-up, but it sounds like Geocortex repackages the Esri product with their own, which is why the JSAPI is available. The best I can do without knowing more would be to put a jsfiddle together doing what you described (I think!):

Interactive Web Map - JSFiddle

I quickly modified the sample you gave and instead of opening the pop-up (infoWindow), the app zooms-in to the extent of the selected polygon. If you want to zoom into a defined urban area within the polygon, this would be more complicated... you would need to have an urban areas layer and need to key off of its extent. I haven't done this before, but I have some ideas of how it could be done.

0 Kudos
GéomatiqueVRN
Occasional Contributor

Thank you for your quick response!

Here are the steps I follow to publish the map on the website:

1 - I author the map in map in ArcGis (v10.3).

2-  I share the service and publish the map service (dynamic) to our ArcGis server.

3- In Geocortex Essentials application, I add the map services I want by specifying the map service URL. In my case, I add a cached base map and the map service created in step 2.

4- In Geocortex, I can modify the Look and feel of the viewer for html5 by adding zoom buttons, query buttons and so on.

5- I save the site and that 's it.

In regards to the zoom extent,  I defined a bookmark zoom for each urban areas in Geocortex. Is it possible to make a mouse click on the map, trigger a specific bookmark based on the polygon we clicked on?

Should the layer specified in the query task URL be a graphic layer to implement mouse events?

Finally, if I want to use my own map to apply what you suggested, all I have to do is modify the index.html file and add the code lines we see in the jsfiddle and substitute the query task URL by the REST URL of the layer I want. Is that correct?

Thank you again

0 Kudos
ChrisSmith7
Honored Contributor

You can do quite a bit in the JSAPI if you are willing to get dirty - the link I shared is a full, working app - you can copy that into an html file (you'll have to add back the headers and css/resources links that jsfiddle wants stripped-out/added elsewhere) and deploy on your web server and the map would work - you can replace the services with your own and modify as needed to work with these services.

Do you have access to modify whatever Geocortex is creating for you? Is it in a friendly format, or minified? If it's friendly, it should be easy enough to modify further the codebase - I'm still not entirely sure how Geocortex works... I've never used it. Another thing you could try is getting in touch with Geocortex to see if they can add this as a feature enhancement for you.

0 Kudos
ChrisSmith7
Honored Contributor

Here's the full app:

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <!--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>QueryTask with geometry, results as an InfoWindow onHover</title>


    <link rel="stylesheet" href="http://js.arcgis.com/3.14/dijit/themes/claro/claro.css">
    <link rel="stylesheet" href="http://js.arcgis.com/3.14/esri/css/esri.css">


    <script src="http://js.arcgis.com/3.14/"></script>
    <script>
        var map;


        require([
            "esri/map",
            "esri/graphic",
            "esri/InfoTemplate",
            "esri/SpatialReference",
            "esri/geometry/Extent",
            "esri/layers/GraphicsLayer",
            "esri/symbols/SimpleFillSymbol",
            "esri/symbols/SimpleLineSymbol",
            "esri/tasks/query",
            "esri/tasks/QueryTask",
            "esri/Color",
            "dojo/domReady!"
        ],
                function (
                Map, Graphic, InfoTemplate, SpatialReference, Extent, GraphicsLayer,
                 SimpleFillSymbol, SimpleLineSymbol, Query, QueryTask, Color
                ) {


            map = new Map("mapDiv", {
                basemap: "streets",
                center: [-80.94, 33.646],
                zoom: 8
            });


            map.on("load", setUpQuery);




            function setUpQuery () {
                                                //set-up listener for county layer click event
            dojo.connect(map.graphics,"onClick",identifyFeatures);
                function identifyFeatures(evt){
                    var extent = evt.graphic.geometry.getExtent();
                    map.setExtent(extent);
                }


                var queryTask = new QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/3");


                //build query filter
                var query = new Query();
                query.returnGeometry = true;
                query.outFields = ["NAME", "POP2000", "POP2007", "POP00_SQMI", "POP07_SQMI"];
                query.outSpatialReference = { "wkid": 102100 };
                query.where = "STATE_NAME = 'South Carolina'";


                var infoTemplate = new InfoTemplate();
                var content = "<b>2000 Population: </b>${POP2000}<br/>" +
                    "<b>2000 Population per Sq. Mi.: </b>${POP00_SQMI}<br/>" +
                    "<b>2007 Population: </b>${POP2007}<br/>" +
                    "<b>2007 Population per Sq. Mi.: </b>${POP07_SQMI}";
                infoTemplate.setTitle("${NAME}");
                infoTemplate.setContent(content);


                map.infoWindow.resize(245, 125);


                //Can listen for complete event to process results
                //or can use the callback option in the queryTask.execute method.
                queryTask.on("complete", function (event) {
                    map.graphics.clear();
                    var highlightSymbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
                                                               new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
                                                                                    new Color([255, 0, 0]), 3), new Color([125, 125, 125, 0.35]));


                    var symbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
                                                      new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
                                                                           new Color([255, 255, 255, 0.35]), 1), new Color([125, 125, 125, 0.35]));


                    var features = event.featureSet.features;
                    var countiesGraphicsLayer = new GraphicsLayer();
                    //QueryTask returns a featureSet.
                    //Loop through features in the featureSet and add them to the map.
                    var featureCount = features.length;
                    for (var i = 0; i < featureCount; i++) {
                        //Get the current feature from the featureSet.
                        var graphic = features; //Feature is a graphic
                        graphic.setSymbol(symbol);
                        graphic.setInfoTemplate(infoTemplate);


                        countiesGraphicsLayer.add(graphic);
                    }
                    map.addLayer(countiesGraphicsLayer);
                    map.graphics.enableMouseEvents();


                    //listen for when the mouse-over event fires on the countiesGraphicsLayer
                    //when fired, create a new graphic with the geometry from event.graphic
                    //and add it to the maps graphics layer
                    countiesGraphicsLayer.on("mouse-over",function (event) {
                        map.graphics.clear();  //use the maps graphics layer as the highlight layer
                        var graphic = event.graphic;
                        map.infoWindow.setContent(graphic.getContent());
                        map.infoWindow.setTitle(graphic.getTitle());
                        var highlightGraphic = new Graphic(graphic.geometry, highlightSymbol);
                        map.graphics.add(highlightGraphic);


                        //uncomment below to show infoWindow contents
                        //map.infoWindow.show(event.screenPoint,
                                          //map.getInfoWindowAnchor(event.screenPoint));
                    });


                    //listen for when map.graphics mouse-out event is fired
                    //and then clear the highlight graphic
                    //and hide the info window
                    map.graphics.on("mouse-out", function () {
                        map.graphics.clear();
                        map.infoWindow.hide();
                    });
                });


                queryTask.execute(query);
            }
        });
    </script>
  </head>


  <body class="claro">
    Hover over a county in South Carolina to get more information.
    <div id="mapDiv" style="width:900px; height:600px; border:1px solid #000;"></div>
  </body>
</html>

If you are unfamiliar with the API, I would start here:

Build your first application | Guide | ArcGIS API for JavaScript

0 Kudos
GéomatiqueVRN
Occasional Contributor

There are two  type of config files that we have access to and that we can modify. An index.html which controls the html page and a Desktop.json.js which is in charge of all the component (modules) of the viewer for html5. The same thing applies for the Tablet and Handheld platforms (Tablet.html, Tablet.json.js, Handhel.html and Handheld.json.js). There are also Style files (css) for each platform.

All these config files can be edited in a text editor. I will try to modify the codebase of the .html config file for each platform by adding the lines of codes above.

In regard to Geocortex, it's an interesting application. Here is their website Geocortex - Accomplish even more with your investment in the ArcGIS platform - Web GIS Mapping Softw...  if you are interested to  take

a look at it.

Thank you again for your time and have a nice weekend!

Badre

0 Kudos