Select to view content in your preferred language

how to call modules in arcgis javascript api

4856
2
05-08-2015 04:37 AM
ugrgr
by
Deactivated User

how to pass parameters like combobox selected items into module from html page and how to call back that module  into html page in arcgis api for javascript, Please give me some sample code to learn.

.

0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus

ugr gr,

   Have you seen the JS api samples page?

Samples | ArcGIS API for JavaScript

ChrisSmith7
Honored Contributor

If you are looking for creating user modules and using them in your application, check out:

Point clustering | ArcGIS API for JavaScript

So, at the top of the main application, you'll see a script tag for dojo config:

    <script>
     
// helpful for understanding dojoConfig.packages vs. dojoConfig.paths:
     
// http://www.sitepen.com/blog/2013/06/20/dojo-faq-what-is-the-difference-packages-vs-paths-vs-aliases/
     
var dojoConfig = {
        paths
: {
          extras
: location.pathname.replace(/\/[^/]+$/, "") + "/extras"
       
}
     
};
   
</script>

The "extras" param will specify the directory to pull the modules. You can then include it like you would an Esri/dojo module:

      var map;
      require
([
       
"extras/ClusterLayer"
     
], function(
       
ClusterLayer
     
) {

Here's where the module lives - http://developers.arcgis.com/javascript/samples/layers_point_clustering/extras/ClusterLayer.js. Then, you can instantiate and interact with the module:

            // cluster layer that uses OpenLayers style clustering
            clusterLayer
= new ClusterLayer({
             
"data": photoInfo.data,
             
"distance": 100,
             
"id": "clusters",
             
"labelColor": "#fff",
             
"labelOffset": 10,
             
"resolution": map.extent.getWidth() / map.width,
             
"singleColor": "#888",
             
"singleTemplate": popupTemplate
           
});

            clusterLayer.setRenderer(renderer);
            map
.addLayer(clusterLayer);

Hope this helps!