Select to view content in your preferred language

adding picturesymbol

606
2
08-10-2012 06:14 AM
PramodHarithsa1
Frequent Contributor
I would like to add a picture symbol on a querytask result(over a poliline layer)
The issue is about the postion attribute.
var graphic = new esri.Graphic(position, simpleMarkerSymbol);
how do i get the mid point of every poly line.
is it like [(xmax-xmin)/2,(ymax-ymin)/2 ]??
0 Kudos
2 Replies
SrikanthNarra
Emerging Contributor
Hi i used this method when i am working with ArcGIS Online

public static MapPoint MidPoint(this Polyline polyline)
    {
        var length = polyline.Length();
        var m = length / 2.0;
        return polyline.LinearPosition(m);
    }


If you are familiar with flex please fallow this example you will get an idea to calculate mid point of polyline

http://gisengineering.blogspot.in/2011/03/determine-midpoint-for-polyline-for.html
0 Kudos
PramodHarithsa1
Frequent Contributor
Hi i used this method when i am working with ArcGIS Online

public static MapPoint MidPoint(this Polyline polyline)
    {
        var length = polyline.Length();
        var m = length / 2.0;
        return polyline.LinearPosition(m);
    }


If you are familiar with flex please fallow this example you will get an idea to calculate mid point of polyline

http://gisengineering.blogspot.in/2011/03/determine-midpoint-for-polyline-for.html


It did something different..
Instead of finding the mid point i went with a point on polyline which is approximately in centre
var graphic = featureSet.features;
                    graphic.setSymbol(symbol);
                    graphic.setInfoTemplate(infoTemplate);
                    var ext = graphic.geometry.getExtent();
                    map.setExtent(ext);
                    var length = graphic.geometry.paths[0].length;
                    var pointxy= graphic.geometry.paths[0][(length/2];
                    var point = new esri.geometry.Point(pointxy[0], pointxy[1], new esri.SpatialReference({ wkid: 102100 }));
                    var simpleMarkerSymbol = new esri.symbol.PictureMarkerSymbol({
                        "type": "esriPMS",
                        "url": "image/E1BA914F.png",
                        "contentType": "image/png",
                        "color": null,
                        "width": 32,
                        "height": 32,
                        "angle": 0,
                        "xoffset": 16,
                        "yoffset": 8
                    });
                    var balloon = new esri.Graphic(point, simpleMarkerSymbol);
                    map.graphics.add(balloon);
0 Kudos