Hi James,
Accoding to your suggesstion I have tried to incorporate the sample code into my application.
I want to display the following points on the map using mil2525 symbology: ( point - lat , long, spatial ref)
Point 1 - 72.852642647560347, 19.092812566811544, SpatialReference::wgs84()),
Point 2 - 72.8708416959572303, 19.08444173689877, SpatialReference::wgs84()),
So I added these points to the point collection using addPoint() in the createGraphic function . No changes have been made to the parseXmlFile function code. Following is the code snippet. Are any more changes needed in the sample code?
void offlinemap2d::addPointsFromStyleFile()
{
//create a new graphicsoverlay
GraphicsOverlay* graphicsOverlay = new GraphicsOverlay(this);
// create the symbology for the points
dictionarySymbolStyle = new DictionarySymbolStyle("mil2525d",":/Res/mil2525d.stylx", this);
DictionaryRenderer* renderer = new DictionaryRenderer(dictionarySymbolStyle, this);
graphicsOverlay->setRenderer(renderer);
//add overlay to the map
parseXmlFile();
m_mapView->graphicsOverlays()->append(graphicsOverlay);
}
void offlinemap2d::createGraphic(QVariantMap rawAttributes)
{
// If _wkid was absent, use WGS 1984 (4326) by default.
int wkid = rawAttributes.count(FIELD_WKID) > 0 ? rawAttributes[FIELD_WKID].toInt() : 4326;
SpatialReference sr(wkid);
Geometry geom;
// It's a multipoint
MultipointBuilder* builder = new MultipointBuilder(sr, this);
PointCollection* collection = new PointCollection(sr, this);
collection->addPoint(72.852642647560347, 19.092812566811544);
collection->addPoint(72.8708416959572303, 19.08444173689877);
builder->setPoints(collection);
geom = builder->toGeometry();
if (!geom.isEmpty())
{
// Get rid of _control_points and _wkid. They are not needed in the graphic's
// attributes.
rawAttributes.remove(FIELD_CONTROL_POINTS);
rawAttributes.remove(FIELD_WKID);
Graphic* graphic = new Graphic(geom, rawAttributes, this);
graphicsOverlay->graphics()->append(graphic);
}
}
Can you also explain what is meant by the control points attribute in the Mil2525DMessages.xml file. Are these control points coordinates where the symbol has to be displayed on the map??