Select to view content in your preferred language

FeatureLayer - compact build - tap events

1941
12
10-18-2011 02:58 PM
GadyPitaru
Emerging Contributor
I am developing an app with the JavaScript API on a mobile website. I'm using the compact build of version 2.5, and I'm having trouble with click/tap events registering on a FeatureLayer to display the InfoWindow with attributes of the clicked graphic. It works fine in the browser, just not when using a mobile device. Any help is much appreciated, here is my code for adding the FeatureLayer to the map:

            var template = new esri.InfoTemplate("<b>${DESCRIPTION}</b>", getTextContent);

            var featureLayer = new esri.layers.FeatureLayer("http://m.skyharbor.com/mapservice/0", {
                mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
                infoTemplate: template,
                outFields: ["DESCRIPTION","Type"],
                opacity: 0
            });
            map.addLayer(featureLayer);
12 Replies
derekswingley1
Deactivated User
What mobile device are you using?
0 Kudos
GadyPitaru
Emerging Contributor
Primarily testing on Android.
0 Kudos
derekswingley1
Deactivated User
No personal experience with Android, but have heard plenty of mixed/negative things about its browser. Are you sure the version you're using supports touch events?
0 Kudos
KellyHutchins
Esri Notable Contributor
Sounds like you are running into this issue - if so try increasing the tolerance.
http://forums.arcgis.com/threads/30061-Android-Click-on-Graphic-Problem?p=100747#post100747
0 Kudos
derekswingley1
Deactivated User
Thanks, Kelly!
0 Kudos
GadyPitaru
Emerging Contributor
Kelly, that is what I was looking for. Thanks!
0 Kudos
GadyPitaru
Emerging Contributor
Actually this isn't working for me. I placed the line of code in the body onload handler and in the map onload handler, and it appeared that the tolerance didn't change, even when clicking a graphic in the browser. Below is some code, maybe I'm missing something?

<head>
    <script type="text/javascript">
    djConfig = {
        parseOnLoad: true,
        baseUrl: "./",
        modulePaths: {
            "mapscript": "./mapscript"
        }
    };
    </script>
    <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.5compact">
    </script>
    <style type="text/css">
      html, body
      {
        height: 100%;
        margin: 0px;
        padding: 0px;
        width: 100%;
      }
    </style>
    <link rel="stylesheet" type="text/css" href="mapscript/infoWindow.css" />
<script type="text/javascript">
        dojo.require("esri.layers.FeatureLayer");
        dojo.require("esri.dijit.InfoWindow");
        dojo.require("mapscript.InfoWindow");

function init() {

    var infoWindow = new mapscript.InfoWindow({
        domNode: dojo.create("div", null, dojo.byId("map"))
    });

    //create map and add layer
    map = new esri.Map("map", {
        logo: false,
        infoWindow: infoWindow
    });

    var template = new esri.InfoTemplate("<b>${DESCRIPTION}</b>", "${Type}");

    var featureLayer = new esri.layers.FeatureLayer("http://server/ArcGIS/rest/MyMapService/MapServer/0", {
        mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
        infoTemplate: template,
        outFields: ["DESCRIPTION","Type"],
        opacity: 0
    });
    featureLayer.setDefinitionExpression("Type IN('Food','Shop','ATM') OR Type LIKE '%Restroom%'");

    map.infoWindow.resize(180, 75);

    var tiledMapServiceLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server/ArcGIS/rest/MyMapService/MapServer");
    map.addLayer(tiledMapServiceLayer);
    map.addLayer(featureLayer);
    //esri.layers._GraphicsContainer.prototype._tolerance = 40; 

    dojo.connect(map, "onLoad", function (evt) {
        //hide zoom slider
        map.hideZoomSlider();
        esri.layers._GraphicsContainer.prototype._tolerance = 40;
    });
}

dojo.addOnLoad(init);
</script>
</head>
<body>
    <div id="map" style="width:100%; height:100%;"></div>
<body>
0 Kudos
samuelxu
Deactivated User
I have the same issue here.  Kelly (ESRI), do you have any idea on this?


Thanks
0 Kudos
KellyHutchins
Esri Notable Contributor
The default tolerance used to be 5 which was did cause difficulties when clicking on Android but now its 15 which in my testing seems to be fine.
I created a quick page and was able to successfully display info windows on an older Android phone ( Motorola Droid with Android 2.2.2).

http://servicesbeta.esri.com/mobile/androidtest.html
0 Kudos