Showing posts with label Arcgis Server. Show all posts
Showing posts with label Arcgis Server. Show all posts

Saturday, February 28, 2009

ArcGIS Silverlight API Developers talk about it in details

The ArcGIS Silverlight API talk about their session of Dev Summit and give some detailed description of what silverlight can, its capabilities, and more download the Broadcast here

Saturday, February 14, 2009

Silverlight 2.0 Books Remommedation

Silverlight API for ArcGIS Server was announced to be realeased in the Developer Summit March 26, so i thought i'll learn some Silverlight, im currently reading the from the following books and recommending them to others.

Wiley - Silverlight 2 Bible
APress - Pro Silverlight 2 in C#

Saturday, January 24, 2009

Tuesday, January 13, 2009

How to accept an invalid SSL certificate programmatically

In my Arclogistics Navigator application, im sending the location of the vehicles to back to our servers in able to see where the vehicles, i created a web service that receives the raw data and process it but it turns out that the web service that is being called over a web service with a certificate that its name doesn't match the server name, calling the client support to resolve this issue would take ages since people here in kuwait are very slow. so i though i'll google a bit to to to know how to accept any certificate no matter what is the error, well this is a POC ;)

here is how you do it

// callback used to validate the certificate in an SSL conversation
private static bool ValidateRemoteCertificate(
object sender,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors policyErrors
)
{
if (Convert.ToBoolean(ConfigurationManager.AppSettings["IgnoreSslErrors"]))
{
// allow any old dodgy certificate...
return true;
}
else
{
return policyErrors == SslPolicyErrors.None;
}
}



what u need to do is to create a parameter in the app.config and give it a key
"IgnoreSslError" and set this to true or false up to ur conviniece and here is how you

streetmps_buffered.TrackingWS.Service m_proxy = new streetmps_buffered.TrackingWS.Service();

ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(ValidateRemoteCertificate);

m_proxy.WriteDataAsync(m_DriverName, m_CurrentGPSPoint.X.ToString(), m_CurrentGPSPoint.Y.ToString(), (int)SMNavigation.MilesToKilometers(m_CurrentSpeed), DateTime.Now.ToString());


hope it helps others

Friday, January 2, 2009

Creating an ESRI Toolbar With ArcGIS Server Flex API

My First Flex ArcGIS Server App was to create a reusable Toolbar with (zoomin , zoomout , pan , zoom to full extent , zoom next , zoom previous) that i can use in all my Flex applications with the ability to set the orientation of the Toolbar (vertical or horizontal), anytime u need toolbar u just have to drag and drop from custom and set two proprties and ur done.

you can view a sample HERE and as its goning to be always you can get the source code HERE

just set 2 properties, ApplicationMap to you Map Id and the ToolbarDirection to horizontal or vertical and ur done

Wednesday, December 17, 2008

Features Disappear after a specific scale ??

here comes the ESRI fun, i have a published which has some invisible layers, at runtime im changing the definition query on different layers, everything works fine but i have noticed yesterday that when i zoom in, the features disappear, BUT not everywhere, in some two areas only.

im still investigating the problem, but still with no luck.

i'll updating on this issue.

UPDATE:

tried all the possibilities with no luck so what i though i would do is to create a new mxd with the same layers and it worked after that. so remember, when you find illogical reason solve it in the illogical way ;)

Print Map with ArcGIS Server

Last week, i was to do some simple map printing of an ArcGIS Server application, the first thing i thought of is Layout view of the map, why this approach won't do the job for me ??

the reason is that im calling SOAP API operation which are stateless operations and it won't effect the Mapservice so there is no way to get that done.

as a start i thought i will take the map image put and put it in another aspx and print it along with the legned that im generating dynamically.

in my application users don't want to display the whole legend, they want to display the legend of some specific layers.

one issue thta i faced in getting the Map Image is that i have 3 rourceitems
1- Graphics Layer
2- non-Cahced Service
3- Cached Service

getting the image the normal would get only the non-chached service image, but found a way to get the image from all the resources for printing.

soon i'll pasting the code with some screenshots.

stay tuned

UPDATE:

create a sub folder in ur project directory or anywhere you want and call it "tmp". the "tmp" folder will be used to save the generated image.

you an extra page lets call it PrintPage.aspx

<%@ Page language="c#" Inherits="Printing.PrintPage" CodeFile="PrintPage.aspx.cs" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>PrintPage</title>
<style type="text/css">

</style>
</head>
<body style="margin:0 0 0 0">
<form id="Form1" method="post" runat="server">
<table border="0" width="100%" align="center">
<tr>
<td style="width: 671px" align="left"><img src="GenerateImage.aspx" id="MapImage" Width="671" Height="606" runat="server" style="border-right: black 1px solid; border-top: black 1px solid; border-left: black 1px solid; border-bottom: black 1px solid" /></td>
<td valign="top" align="left">
<asp:GridView id="GVLegend" runat="server" Width="129px" Height="63px" GridLines="Horizontal" EmptyDataText="No Legend" AutoGenerateColumns="False">
<Columns>
<asp:ImageField DataImageUrlField="LegendImage">
<ItemStyle Height="40px" Width="30px" />
</asp:ImageField>
<asp:BoundField DataField="LegendName" >
<ItemStyle Font-Size="Smaller" />
</asp:BoundField>
</Columns>
</asp:GridView>
</td>
</tr>
</table>
</form>
</body>
</html>



the code behind PrintPage.aspx.cs


using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using ESRI.ArcGIS.ADF.Web;

namespace Printing
{
public partial class PrintPage : System.Web.UI.Page
{
protected void Page_Load(object sender, System.EventArgs e)
{
MapImage.Src = Session["MapImageURL"].ToString();
}
}

}



in you default.aspx add a button that causes a callback to this function

public void PrintMap()
{
string MapImageURL = GISFunctions.ExportMapImage(Map1, Page.Request.PhysicalApplicationPath + @"tmp\");
Session["MapImageURL"] = "tmp/" + MapImageURL;


Map1.CallbackResults.Add(GeneralUtilities.Utilities.GetCallBack(null,null,"javascript","window.open('" + "PrintPage.aspx', 'PrintWindow', 'dependent=yes ,width=800, height=500, status=no, toolbar=no, menubar=yes, location=no, resizable=yes, scrollbars=yes');"));
mapstring = Map1.CallbackResults.ToString();
}


the ExportMapImage function code

public static string ExportMapImage(ESRI.ArcGIS.ADF.Web.UI.WebControls.Map ADFMap, string OutputPath)
{
System.Collections.Generic.List<System.Drawing.Image> bitmaps = new System.Collections.Generic.List<System.Drawing.Image>();
foreach (ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality mf in ADFMap.GetFunctionalities())
{
if (mf != null)
{
ESRI.ArcGIS.ADF.Web.MapImage mapImage = mf.DrawExtent(ADFMap.Extent);

mapImage = mf.DrawExtent(ADFMap.Extent);
if (mapImage == null)
continue;
if (mapImage.GetImage() != null)
{
bitmaps.Add(mapImage.GetImage());
}
}
}

System.Drawing.Bitmap newImg = new System.Drawing.Bitmap(Convert.ToInt16(ADFMap.Width.Value), Convert.ToInt16(ADFMap.Height.Value));

System.Drawing.Graphics imgGraphics = System.Drawing.Graphics.FromImage(newImg);
int i = bitmaps.Count - 1;
while (i >= 0)
{
imgGraphics.DrawImage(bitmaps[i], 0, 0, Convert.ToInt16(ADFMap.Width.Value), Convert.ToInt16(ADFMap.Height.Value));
i += -1;
}
long Ticks = DateTime.Now.Ticks;
string ImagePath = OutputPath + "mapimage" + Ticks + ".jpg";
newImg.Save(ImagePath, System.Drawing.Imaging.ImageFormat.Jpeg);

return "mapimage" + Ticks + ".jpg";
}


in the same way, you can add the legend next to the map, the reason why i didn't add it in code in the im displaying the legend based on different criterias which i didn't want to confuse others including it my code, but still if u need to know how to generate the legend, can can mail me.

Wednesday, December 10, 2008

"Cannot open map cache" A Good Start

yesterday night, 4 hours trying to deploy a very simple ArcGIS Mobile application on my Pocket PC 2003 but with no luck, the path of the cache is right and specified in the mapcache "storage" well, i found out that im not the only one who is in this trouble,

http://forums.esri.com/Thread.asp?c=206&f=2274&t=231067
http://forums.esri.com/Thread.asp?c=206&f=2295&t=218141
http://forums.esri.com/Thread.asp?c=206&f=2274&t=256129
http://forums.esri.com/Thread.asp?c=206&f=2295&t=223604

the strange thing is that when you debug the application, it works well and you get the cache like a charm, but when i deploy the application through a .CAB created through "Smart Device CAB Project" i get the lovely "Cannot open map cache". im investigating more into this and i will report back.

Monday, December 8, 2008

Hello,

Hey,

very soon i'll be starting this blog where i will be sharing my ideas and all the problems that im facing doing my arcgis server tasks, basically i was a web developer for a couple of years working on some open source stuff (LAMP) but later i joined a company that i had to do only gis in it, first couple of months where very toughh but later i started enjoying it, will be sharing all the enjoyment together ;)

you can subscribe to to RSS feeds to have upto date info,

Regards,
Noureddine El-Zaatari