AnsweredAssumed Answered

Problem with custom modules

Question asked by peterm_erm on Oct 16, 2013
Latest reply on Oct 17, 2013 by geonetadmin
Hi All,

I am trying to practice accessing content from custom modules using the Home Button sample from the API tutorials. I have saved the HomeButton.js and the HTML page in the folder structure which is attached as images.

I have written the following HTML page to load the HomeButton but I get an "Object doesn't support this action" error when the page attempts to create a new HomeButton object.

I suspect that the issue is with the way I have entered the path to my custom module but I have tried loads of combinations and cant seem to find a solution.

The code is below and any help would be greatly appreciated!

Peter

<!DOCTYPE HTML>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
    <title>Home Extent Button Dijit</title>
    <link rel="stylesheet" type="text/css" href="http://js.arcgis.com/3.7/js/esri/css/esri.css">
    <link rel="stylesheet" type="text/css" href="http://js.arcgis.com/3.7/js/dojo/dijit/themes/claro/claro.css">
    <link rel="stylesheet" type="text/css" href="./ERMWidgets/css/HomeButton.css">
    <style type="text/css">
    body{
            margin:40px;
            padding:20px;
        }
        .container{
            position:relative;
            padding: 10px;
            border: 1px solid #eee;
            -webkit-border-radius: 3px;
            border-radius: 3px;
        }
        #map{
            width:100%;
            height: 500px;
            position: relative;
        }
        #HomeButton{
            position: absolute;
            top:95px;
            left: 20px;
            z-index: 50;
        }
    </style>
</head>
<body class="claro">
    <div class="container">
        <div id="map" class="map">
            <div id="HomeButton"></div>
        </div>
    </div>
    <h2>All Options</h2>

    <script src="http://js.arcgis.com/3.7/" type="text/javascript"></script>
    <script type="text/javascript">

       var dojoConfig = {
            async: true,
            parseOnLoad: true,
            isDebug: true,
            packages:[{
                "name": "ERMWidgets",
                "location": location.pathname.replace(/\/[^/]+$/, '') + "/ERMWidgets/"
            }]
        };

        require(["esri/map", "ERMWidgets/HomeButton", "dojo/on"], function(Map, HomeButton, on){

            var myMap = new Map("map", {
                center: [-56.049, 38.485],
                zoom: 3,
                basemap: "streets"
            });

            
            
            var myWidget = new HomeButton({
                map: myMap
            },"HomeButton");
            
            myWidget.on('home', function(obj){
                 console.log(obj);
            });
            
            myWidget.startup();
            
            

        });
    </script>
</body>
</html>

Attachments

Outcomes