Hi,
I developed a custom map provider with two mapsources (one for road and one for aerial maps): is there a way to change the mapsource via the "eye" button of the map control?
For example BingMapProvider has Aerial, Road, Bird's eye and so on shown when you click on the "eye" button, but when I set my custom MapProvider a see no mapsource choice.
this is my code:
public class HereMapProvider : TiledProvider
{
/// <summary>
/// Initializes a new instance of the MyMapProvider class.
/// </summary>
public HereMapProvider()
: base()
{
HereMapSource source = new HereMapSource();
this.MapSources.Add(source.UniqueId, source);
HereAerialMapSource source1 = new HereAerialMapSource();
this.MapSources.Add(source1.UniqueId, source1);
}
/// <summary>
/// Returns the SpatialReference for the map provider.
/// </summary>
public override ISpatialReference SpatialReference
{
get
{
return new MercatorProjection();
}
}
}
public class HereAerialMapSource : TiledMapSource
{
/// <summary>
/// Initializes a new instance of the MyMapSource class.
/// </summary>
public HereAerialMapSource()
: base(1, 20, 256, 256)
{
}
/// <summary>
/// Initialize provider.
/// </summary>
public override void Initialize()
{
// Raise provider initialized event.
this.RaiseIntializeCompleted();
}
/// <summary>
/// Gets the image URI.
/// </summary>
/// <param name="tileLevel">Tile level.</param>
/// <param name="tilePositionX">Tile X.</param>
/// <param name="tilePositionY">Tile Y.</param>
/// <returns>URI of image.</returns>
protected override Uri GetTile(int tileLevel, int tilePositionX, int tilePositionY)
{
int zoomLevel = ConvertTileToZoomLevel(tileLevel);
// Prepare tile url somehow ...
string url = getUrl(zoomLevel, tilePositionX, tilePositionY);//CustomHelper.GetTileUrl(tileLevel, tilePositionX, tilePositionY);
return new Uri(url);
}
private string getUrl(int tileLevel, int tilePositionX, int tilePositionY)
{
return @"http://1.aerial.maps.cit.api.here.com/maptile/2.1/basetile/newest/hybrid.day/" + tileLevel + "/" + tilePositionX + "/" + tilePositionY + "/256/png8?app_id=XXX&app_code=XXX&start=geo!";
}
}
public class HereMapSource : TiledMapSource
{
/// <summary>
/// Initializes a new instance of the MyMapSource class.
/// </summary>
public HereMapSource()
: base(1, 20, 256, 256)
{
}
/// <summary>
/// Initialize provider.
/// </summary>
public override void Initialize()
{
// Raise provider initialized event.
this.RaiseIntializeCompleted();
}
/// <summary>
/// Gets the image URI.
/// </summary>
/// <param name="tileLevel">Tile level.</param>
/// <param name="tilePositionX">Tile X.</param>
/// <param name="tilePositionY">Tile Y.</param>
/// <returns>URI of image.</returns>
protected override Uri GetTile(int tileLevel, int tilePositionX, int tilePositionY)
{
int zoomLevel = ConvertTileToZoomLevel(tileLevel);
// Prepare tile url somehow ...
string url = getUrl(zoomLevel, tilePositionX, tilePositionY);//CustomHelper.GetTileUrl(tileLevel, tilePositionX, tilePositionY);
return new Uri(url);
}
private string getUrl(int tileLevel, int tilePositionX, int tilePositionY)
{
return @"http://1.base.maps.cit.api.here.com/maptile/2.1/maptile/newest/normal.day/" + tileLevel + "/" + tilePositionX + "/" + tilePositionY + "/256/png8?app_id=XXX&app_code=XXX&start=geo!";
}
}
I developed a custom map provider with two mapsources (one for road and one for aerial maps): is there a way to change the mapsource via the "eye" button of the map control?
For example BingMapProvider has Aerial, Road, Bird's eye and so on shown when you click on the "eye" button, but when I set my custom MapProvider a see no mapsource choice.
this is my code:
public class HereMapProvider : TiledProvider
{
/// <summary>
/// Initializes a new instance of the MyMapProvider class.
/// </summary>
public HereMapProvider()
: base()
{
HereMapSource source = new HereMapSource();
this.MapSources.Add(source.UniqueId, source);
HereAerialMapSource source1 = new HereAerialMapSource();
this.MapSources.Add(source1.UniqueId, source1);
}
/// <summary>
/// Returns the SpatialReference for the map provider.
/// </summary>
public override ISpatialReference SpatialReference
{
get
{
return new MercatorProjection();
}
}
}
public class HereAerialMapSource : TiledMapSource
{
/// <summary>
/// Initializes a new instance of the MyMapSource class.
/// </summary>
public HereAerialMapSource()
: base(1, 20, 256, 256)
{
}
/// <summary>
/// Initialize provider.
/// </summary>
public override void Initialize()
{
// Raise provider initialized event.
this.RaiseIntializeCompleted();
}
/// <summary>
/// Gets the image URI.
/// </summary>
/// <param name="tileLevel">Tile level.</param>
/// <param name="tilePositionX">Tile X.</param>
/// <param name="tilePositionY">Tile Y.</param>
/// <returns>URI of image.</returns>
protected override Uri GetTile(int tileLevel, int tilePositionX, int tilePositionY)
{
int zoomLevel = ConvertTileToZoomLevel(tileLevel);
// Prepare tile url somehow ...
string url = getUrl(zoomLevel, tilePositionX, tilePositionY);//CustomHelper.GetTileUrl(tileLevel, tilePositionX, tilePositionY);
return new Uri(url);
}
private string getUrl(int tileLevel, int tilePositionX, int tilePositionY)
{
return @"http://1.aerial.maps.cit.api.here.com/maptile/2.1/basetile/newest/hybrid.day/" + tileLevel + "/" + tilePositionX + "/" + tilePositionY + "/256/png8?app_id=XXX&app_code=XXX&start=geo!";
}
}
public class HereMapSource : TiledMapSource
{
/// <summary>
/// Initializes a new instance of the MyMapSource class.
/// </summary>
public HereMapSource()
: base(1, 20, 256, 256)
{
}
/// <summary>
/// Initialize provider.
/// </summary>
public override void Initialize()
{
// Raise provider initialized event.
this.RaiseIntializeCompleted();
}
/// <summary>
/// Gets the image URI.
/// </summary>
/// <param name="tileLevel">Tile level.</param>
/// <param name="tilePositionX">Tile X.</param>
/// <param name="tilePositionY">Tile Y.</param>
/// <returns>URI of image.</returns>
protected override Uri GetTile(int tileLevel, int tilePositionX, int tilePositionY)
{
int zoomLevel = ConvertTileToZoomLevel(tileLevel);
// Prepare tile url somehow ...
string url = getUrl(zoomLevel, tilePositionX, tilePositionY);//CustomHelper.GetTileUrl(tileLevel, tilePositionX, tilePositionY);
return new Uri(url);
}
private string getUrl(int tileLevel, int tilePositionX, int tilePositionY)
{
return @"http://1.base.maps.cit.api.here.com/maptile/2.1/maptile/newest/normal.day/" + tileLevel + "/" + tilePositionX + "/" + tilePositionY + "/256/png8?app_id=XXX&app_code=XXX&start=geo!";
}
}