Monday, December 29, 2008

Flex 3 Books Remommedation

Before i start down with ESRI FLEX API i had to start with Flex itself, having a Adobe Flash 8 Experience, i didn't find it much difficult, but with some new concepts and it was easy to grasp.

I would recommend the following book to anyone starting Flex 3 with Adobe Flex Builder.

OReilly.Learning.Flex.3.Jun.2008 (Read This First)
O'Reilly - Flex 3 Cookbook - May 2008
Oreilly Getting Started With Flex 3 Jun 2008


UPDATE

To get ur self more familiar with the contols and how to apply style to them i recommend the following links

Flex Component Explorer

Flex Style Explorer

Wednesday, December 24, 2008

ArcGIS Server Flex API

I started missing around with ArcGIS Server Flex API, as a UI, its perfect but with very limited functionalities, of course everything can be achieved but with web services,

be tuned for some tutorials.

Sunday, December 21, 2008

Control "CONTROL_NAME" or type "CONTROL_TYPE" must be placed inside a form tag with runat=server

today morning i was migrating an Arcgis server application from 9.2 to 9.3 where i had some custom made tools in the toolbar, one of the tools is rebinding a gridview control and refreshing it. but i was getting a strange following message Control "FPLegend_CGresults" or type "Gridview" must be placed inside a form tag with runat=server.



the first moment i thought that esri changed the way we do callbacks but google a bit i found out the solution but im not convinced with the error since i have my control within a form tag with runat=server.

still invistigating into it but here is how you can fix the problem:

in you default.aspx <@ page..> add the following attribute EnableEventValidation="false"

in your default.aspx.cs override the following VerifyRenderingInServerForm() function like this

public override void VerifyRenderingInServerForm(Control control)
{
//base.VerifyRenderingInServerForm(control);
//
}


hope this helps others

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.

Friday, December 12, 2008

ESRI StreetMap Mobile (ArcLogistics Navigator) on a Pocket PC 2003

Last August, i have developed a a navigation application with routing functionality but it was made to run on a ruggedized (xplore) pc with windows xp tablet edition. a couple o days a ago, i got a pocket pc 2003 so i thought i would try to migrate my application to run on the pocket pc, well during the migration, i faced many problem,

  1. you need to register smmobile.dll on the device.
  2. picturebox.CreateGraphics() function doesn't work on the .NET CF.
  3. you need to migrate ur all ur custome made controls and dlls to work with the device.
  4. IMapDocument.GetRouter() returns an Exception "Unable to obtain server's security context" with ErrorCode: -2147220991
many are in the way i pretty sure, i will reporting back with the solutions once im done, but its not a pleasent experience at all since that StreetMap Mobile is not anymore included in the EDN and its now is included in the special services & the samples are in C# windows applications.

wish me luck

UPDATE:

You need to register smmobile.dll on the device:
for this, actually it was not straight forward, i had to experiment and brain storm, first of all, SM help doesn't show show anything about programming on mobile devices and all the examples are done for VB.NET, to register a smmobile.dll com, you need the regsvrce.exe which is made for mobile devices, you just need to upload it to the device and and run it from the device and it will ask you for the full path of the dll you want to register.

the second part of this process is the smmobile.dll, well the one which you find in the C:\Program Files\StreetMapMobile\bin when install it doesn't register, and it shows an error "LoadLibrary [filepath] failed GetLastError Returns c1" well, digging more into this i found out that the dll is not compiled for mobile devices and you need to re-compile the dll for a mobile device ?? ehmm ehmm, there is now way to get that unless you get the source ?? right !!. i started looking around and i found the installation for the ESRI Navigator sample but that was C:\Program Files\StreetMapMobile\SampleApps\WM5_PocketPC\ESRINavigator.CAB, i extracted it and i was searching in the files and i saw a file named like this "smmobile.058" so i thought that this is for sure the file, i changed its extension to .dll and uploaded it to the device and BANG, it registered. here are the links for regsvrce.exe and smmobile.dll


picturebox.CreateGraphics() function doesn't work on the .NET CF:

the Control.CreateGraphics() is supported in .NET CF 3.5 only and any version prior to that, need to override the paint method of the control, look at this discussion here.

you need to migrate ur all ur custome made controls and dlls to work with the device.

if you have developed a class library or a control library, you need to redevelop the same for the same device in order to work with your project, and believe me, it is not the same ?? you will amazed that many functions are not available in the CF where you have to find workaround for example, i had a panel with double buffering enabled usercontrol, and now i can't enable double buffering anymore !!

Thursday, December 11, 2008

"SERVICE_NAME.MapServer.cfg could not be started" Error Message

last week, we have a kind of distributed installation of a ArcGIS Server 9.3, one SOM and a SOC on another machine, no load balance or anything else, the installation was very smooth,

the SOC machine was intstalled and added to as a host to the SOM and it was publishing like a charm, then we thought of adding the a local SOC to the server, and then the fun started !!

after adding the Local SOC we are getting this message "SERVICE_NAME.MapServer.cfg could not be started" message made us feel really happy, solving this prblems took nearly 1.5 days experimneting and re-installation but WE "FORGOT" to take a look at the log.

the next day early in the morning, i took a look at the log and it was something silly,

when you install a SOC only on a standalone machine, it doesn't create "arcgisserver" that has the "arcgiscache" , "arcgisoutput" , and "arcgisjobs" and i really dunno why, it should create all this by it self and set the permissions

we created these things manually and everyhing worked after that, well i hope that this might be usefull to everyone else, something to note that if you ever get this message then the folder might be there but with a permission set to ArcGISSOC local account.

i hope it helps others

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.

Tuesday, December 9, 2008

ArcGIS Server 9.3 & AjaxControlToolKit Javascript Errors

many of the projects that i develop have ajax in them and i spicifically i use AjaxControlToolKit, well i had a couple of mapping applications developed in 9.2 and they use AjaxControlToolKit and projects works like a charm but when migrating to 9.3 have faced javascript errors that i couldn't solve , the following:

Sys.InvalidOperationException: Type Sys.Timer has already been registered.

Sys.InvalidOperationException: Type AjaxControlToolkit.BoxSide has already been registered.

Sys.InvalidOperationException: Type AjaxControlToolkit.Animation.Animation has already been registered.

well i have already posted a thread on ESRI forum here, and i got no responese till now, digging more into this issue, it turns out that when having AjaxControlToolkit.dll in ur bin directory and referencing it in ur project causes these errors only with 9.3 controls, invistigating more i found out that AjaxControlToolkit.dll is registered in the windows assembly when installing ArcGIS Server 9.3.

if u want things to work well, just reference the toolkit .dll from .NET assemblies, you will find it there and everything should work well, im talking about version 1.0.10920.32880 but if you want version 3.0.20229.20843 or higher to work with 9.3 ADF, you need to follow this article.

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