Maps > Map Projections > Adding Graphic Objects on Top of an Imported Map > Getting Map Information
 
Getting Map Information
In Rogue Wave® Views Maps, map information can be attached to managers using the IlvMapInfo class. This class encapsulates the IlvProjection and IlvMapAdapter to convert coordinates between map coordinates and manager coordinates.
To get the IlvMapInfo that is attached to an IlvManager, you use the static function IlvMapInfo::Get, as in our sample:
_mapInfo = IlvMapInfo::Get(manager);
Adding Cities
The addCities method adds a number of cities on top of the imported map of the United States:
void
SimpleMapViewer::addCities()
{
addCity("Washington", "39D11’N", "76D51W");
addCity("New York", "40D59’N", "73D39’W");
addCity("Miami", "25D58’N", "80D02’W");
addCity("San Francisco", "37D44’N", "122D20’W");
addCity("Seattle", "47D51’N", "122D01’W");
addCity("Denvers", "39D50’N", "104D53’W");
}
The addCity method first computes the latitude and the longitude of the cities to be displayed:
void
SimpleMapViewer::addCity(const char* cityName,
const char* latString,
const char* longString)
{
double latitude;
IlvMaps::DMSToRadian(latString, latitude);
double longitude;
IlvMaps::DMSToRadian(longString, longitude);
IlvCoordinate c(longitude, latitude);
After the geographic coordinates of the city is computed, this method uses the _mapInfo of our map to convert these coordinates to manager coordinates. This conversion effectively converts the geographic coordinates to the cartesian coordinates of the projection, then convert these coordinates into manager units. Note that the conversion status is to be tested, as coordinate conversion in projection coordinate system can lead to errors:
IlvMapsError status = IlvMaps::NoError();
IlvPoint p;
status = _mapInfo->forward(c, p);
Once the coordinates are converted and that no error occurs in the conversion process, we add the city as a red marker:
if (status == IlvMaps::NoError()) {
IlvMarker* marker = new IlvMarker(_container->getDisplay(),
p,
IlvMarkerFilledDiamond);
marker->setSize(4);
marker->setForeground(_container->getDisplay()->getColor("red"));
IlvManager* manager = _managerRectangle->getManager();
manager->addObject(marker, 1, IlFalse);
marker->setName(cityName);
}

Version 6.1
Copyright © 2016, Rogue Wave Software, Inc. All Rights Reserved.