I have a web map with a few points and a single polyline. I have infoTemplate(s) attached to the points and tried to replicate this to the polyline however, I can't get it to work. I looked on the ArcGIS API for JavaScript site and found an example against a polygon (hover) which is close but I need an example based on a polyline. Does anyone have a code sample that works for this request? Thanks!


The following code should work to attach an infoTemplate to a polyline.

        var infoTemplate = new InfoTemplate();
        infoTemplate.setTitle("Your Title");
        infoTemplate.setContent("field1 label: w ${field1}<br/>" +
            "field2 label: ${field1}");

        polyline = new FeatureLayer("[Your Rest Endpoint URL]", {
            mode: FeatureLayer.MODE_ONDEMAND,
            infoTemplate: infoTemplate,
            outFields: ["field1", "field2"]


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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