This question is locked. New answers and comments are not allowed.
I Have 2 questions
I create my own provider.
1-> I have a bug on my provider that when i use the following code to set the map center
this.PergoMap.Center = new Location { Latitude = 78.174140351324, Longitude = 32.8532699990176 };
it is showing incorrect point and the coordinates location is
Latitude = 39.087070175662, Longitude = 32.8532699990176
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Telerik.Windows.Controls.Map;
using System.Text;
namespace Pergo.Silver.Views.ctrl
{
public class PergoProvider : MapProviderBase
{
public string mapServiceUrl { get; set; }
public string Token { get; set; }
public PergoProvider(MapMode mode, bool labelVisible) :
base(mode, labelVisible)
{
mapServiceUrl = @"map{0}.pergo.com.tr";
}
#region .. Long-lat Max-Min
public override double MinLatitude
{
get
{
return -85.05112878;//base.MinLatitude;
}
}
public override double MaxLatitude
{
get
{
return 85.05112878; //base.MaxLatitude;
}
}
public override double MaxLongitude
{
get
{
return 180.0;//base.MaxLongitude;
}
}
public override double MinLongitude
{
get
{
return -180.0;// base.MinLongitude;
}
}
#endregion
public override MapProviderBase GetSource(MapMode mode, bool isLabelVisible)
{
return this;
}
public override ISpatialReference SpatialReference
{
get
{
return new MercatorProjection();
}
}
public override Size TileSize
{
get
{
return new Size(base.TileSize.Width , base.TileSize.Height);
}
}
public override Uri GetTile(int tileLevel, int tilePositionX, int tilePositionY)
{
int zoomLevel = this.ConvertTileToZoomLevel(tileLevel) - 1;
if (zoomLevel == -1)
return null;
string URL = "";
double nullvalue = Math.Pow(2, Convert.ToDouble(zoomLevel))-1;
if (tilePositionY > nullvalue)
return null;
else tilePositionY = Convert.ToInt32(nullvalue) - tilePositionY;
string x = tilePositionX.ToString("000000000").Insert(3, "/").Insert(7, "/"); // - 000/000/001
string y = tilePositionY.ToString("000000000").Insert(3, "/").Insert(7, "/"); // - 000/000/000
URL = string.Format("http://" + mapServiceUrl + "/tile/{1:00}/{2}/{3}.png", GetServerNum(tilePositionX, tilePositionY, 4), zoomLevel, x, y);
//URL = string.Format("http://" + "map0.pergo.com.tr" + "/tile/{0:00}/{1}/{2}.png", zoomLevel, x, y);
return new Uri(URL);
}
internal int GetServerNum(int tilePositionX,int tilePositionY, int max)
{
return (tilePositionX + 2 * tilePositionY) % max;
}
public override void Initialize()
{
}
public override bool IsLabelSupported
{
get { return false; }
}
public override bool IsModeSupported(MapMode mode)
{
return false;
}
public override System.Collections.Generic.IEnumerable<MapMode> SupportedModes
{
get { return null; }
}
public override int MaxZoomLevel
{
get
{
return base.MaxZoomLevel;
}
set
{
base.MaxZoomLevel = value;
}
}
public override int MinZoomLevel
{
get
{
return base.MinZoomLevel;
}
set
{
base.MinZoomLevel = value;
}
}
protected override bool IsValidTileLevel(int tileLevel)
{
return base.IsValidTileLevel(tileLevel);
}
protected override void OnMapModeChanged(MapMode oldMode, MapMode newMode)
{
}
}
}
1-> When i adding content control to my map it is looking upper left side on the map control and when i change the map center they also sliding with map.
internal
void clnt_GetAllTerminalCompleted(object sender, PergoWCF.GetAllTerminalCompletedEventArgs e) { const string DefaultStyle = "defaultStyle"; List<object> objects = new List<object>(); if (e.Error == null) { foreach (Terminal terminalLocation in e.Result) { ContentControl terminal = new ContentControl(); terminal.DataContext = terminalLocation.ShortName; string styleName = DefaultStyle; styleName = "marketStyle"; if (this.dynamicLayer.Items.Contains(terminal)) continue; try { terminal.Style = this.PergoMap.Resources[styleName] as Style; } catch (Exception) { terminal.Style = this.PergoMap.Resources[DefaultStyle] as Style; } terminal.SetValue(MapLayer.LocationProperty, new Telerik.Windows.Controls.Map.Location(Convert.ToDouble(terminalLocation.Latitude), Convert.ToDouble(terminalLocation.Longitude))); ToolTip tooltip = new ToolTip(); tooltip.Content = "Click to select"; terminal.MouseLeftButtonDown += new MouseButtonEventHandler(area_MouseLeftButtonDown); //else //{ // tooltip.Content = "Click to select or unselect"; // store.MouseLeftButtonDown += new MouseButtonEventHandler(store_MouseLeftButtonDown); //} ToolTipService.SetToolTip(terminal, tooltip); objects.Add(terminal); } Action<System.Collections.ICollection> callback = e.UserState as Action<System.Collections.ICollection>; callback(objects); } }
public class DynamicSource : IMapDynamicSource { private Map page; public DynamicSource(Map examplePage) { this.page = examplePage; } /// <summary> /// The method requests data from the web service according to zoom level and location area /// </summary> /// <param name="minZoom">Minimal zoom.</param> /// <param name="maxZoom">Maximal zoom.</param> /// <param name="upperLeft">Upper left coordinate.</param> /// <param name="lowerRight">Lower right coordinate.</param> /// <param name="callback">Callback.</param> public void ItemsRequest(double minZoom, double maxZoom, Telerik.Windows.Controls.Map.Location upperLeft, Telerik.Windows.Controls.Map.Location lowerRight, Action<System.Collections.ICollection> callback) { PergoWCF.WCFClient client = new WCFClient(); client.GetAllTerminalCompleted += page.clnt_GetAllTerminalCompleted; if (minZoom == 3) { // request areas try { client.GetAllTerminalAsync(callback); } catch (Exception ex) { throw ex; } } if (minZoom == 9) { // request stores try { client.GetAllTerminalAsync(callback); } catch (Exception ex) { throw ex; } } } }}