Creation of custom map source is impossible even after adding new MapSource type into MapSourceKind enum.
The project will compile however at runtime will fail, because singletone object MapSourceMgr that is lays in bundled library MAP has no way to handle (or knowing) new map type.
The constructor contents:
//-------------------------------------------------------------------------
MapSourceMgr::MapSourceMgr( ) :
//-------------------------------------------------------------------------
mMap( )
{
for ( int i = 0; i < MapSourceKind_Last; i++ )
mMap[(MapSourceKind)i] = NULL;
mMap[MapSourceKind_OpenStreetMap] = newobject( OpenStreetMapSource, new OpenStreetMapSource( ) );
mMap[MapSourceKind_GoogleMap] = newobject( GoogleMapSource, new GoogleMapSource( GoogleMapsMapKind_StreetMap ) );
mMap[MapSourceKind_GoogleAerial] = newobject( GoogleMapSource, new GoogleMapSource( GoogleMapsMapKind_Aerial ) );
mMap[MapSourceKind_GoogleHybrid] = newobject( GoogleMapSource, new GoogleMapSource( GoogleMapsMapKind_Hybrid ) );
mMap[MapSourceKind_CloudMade1] = newobject( CloudMadeMapSource, new CloudMadeMapSource( 1 ) );
mMap[MapSourceKind_CloudMade7] = newobject( CloudMadeMapSource, new CloudMadeMapSource( 7 ) );
//mMap[MapSourceKind_VirtualEarth] = newobject( VirtualEarthMapSource, new VirtualEarthMapSource( ) );
}
So as it shown - no instances of other types created, then letter when Widget will try to set map source to new one application will crash.
It would be wise to add an method to add/remove MapSource types at run time. Since all of that type maps differs in source of tiles it may be better to no create SourceType class for each map (google, OSM ... ) but to add just tile's URL template, as it done in JavaScript API of those map engines.
I mean:
instead of
void OpenStreetMapSource::getTileUrl( char* buffer, MapTileCoordinate tileXY )
//-------------------------------------------------------------------------
{
sprintf( buffer, "http://tile.openstreetmap.org/%d/%d/%d.png", tileXY.getMagnification( ), tileXY.getX( ), tileXY.getY( ) );
}
have something like:
void GenericMapSource::setTileUrlTemplate(char *buffer){
mTileUrlTemplate = buffer; // buffer="http://tile.openstreetmap.org/%d/%d/%d.png"
}
void GenericMapSource::getTileUrl( char* buffer, MapTileCoordinate tileXY )
//-------------------------------------------------------------------------
{
sprintf( buffer, mTileUrlTemplate, tileXY.getMagnification( ), tileXY.getX( ), tileXY.getY( ) );
}
So the Developer may change tiles on the fly (like day/night map ).