Showing posts with label Web. Show all posts
Showing posts with label Web. Show all posts

Sunday, February 6, 2011

Kickoff! And It's Not The Super Bowl

I just wanted to share with my visitors that what appears to be limited site activity; is just an appearance to be limited activity. I hope you are ready. But it does not matter if you are not. You can even be confused as that will be ideal, because what you need is clarity.

Professional Programmers Should Provide Clarity

Learning about computers should not be difficult.

In my next post, I will share you the bare bones of web development.

We are going for the how to approach. And what I am going to share with you, many other professionals, companies and support for books you buy, will not.

Here is what others are concerned about that I am not:
  • Job Security - what I share will be the best of what I know, but will be nothing compared to what I will know. I focus on constant improvement and believe sharing among professionals is valuable for all.
  • Making Money Doing This - money can be good, but my focus is on quality first. If you like what you read and it helps you, please donate to my paypal account. The money will be used to invest in the development community so as I grow, you can too.
  • Making my blog the center of the universe - If you have something valuable to share, I would rather share it that re-write it.

A few paragraphs and three dot points aren't enough to tell you about what I want to share with you, so follow along for a little while. I don't expect your trust until I earn it.

So, I ask that you give me a chance to prove that my focus is on you, for one reason.

I think it's time for people to be treated like people by providing the personal touch. I have a budget of $0.00, no staff, and extremely limited resources. Luckily, that's enough.

All of this is free. But, there is a catch. I want you to get involved, so I can grow and you can too.

Talk to you soon.

Chris

Saturday, November 13, 2010

ESRI Print Task Sample for the JSAPI 2.1


I failed at giving myself deadlines, so I thought I would challenge myself. There are examples of creating a PrintTask, but they seem to be hard to follow, at least for me. If you have found this to be the case, then this utility and post is for you. This example will be very basic as will show you how to print a map to pdf using the ESRI ArcGIS Server JSAPI 2.1; but just the map. To simplify the code, I have not included code to format the pdf itself. This is a how to, because any solution is better than no solution when a solution is needed. There are only two blocks of code in the entire application; one block in JavaScript and one in VB.NET so don't let the details of this post overwhelm you.

Well I just finished writing the PrintTask for the ESRI ArcGIS Server JSAPI 2.1. It took me 45 minutes to build the site from scratch. Unfortunately, I missed a parameter that I was passing and it slowed down my development time. It then took me the additional time to write this blog, not to mention adding the images manually after writing the blog in MS Word. But now the blog and the utility are ready.

I used ESRI's web service in the REST API at http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapServer which displays below in the exportMap.aspx. Yes, a .NET page using the JSAPI.


What happened? We used the .NET control and had it run some JavaScript on the ClientClick event and then passed the variable to a label .NET control. If you have had problems in the past with using .NET controls with the ESRI JSAPI, you may need to lay out the button like the following image.


With that in place, we can click on our .NET button with worrying about the page refreshing. Be careful! Not including the ContentTemplate tag within the UpdatePanel and surrounding the Button will make your application crash. I have been there a few times.
So, we click our button and then just for you information, a JavaScript message comes up. Everything is going smooth so far if you see this.


A new browser window opens, but before we look at that. Check out what displayed on our page of the world right above the Print Map button. Where did that come from?


Before we can print the image, we need to use the export function. You can read more about exportImage in ESRI online documentation at http://resources.esri.com/help/9.3/arcgisserver/apis/rest/index.html?export.html.
But, what about the code? If you have a hard time following it, let me take you through it.
Remember our .NET control? Take a look below and you will see that the OnClientClick event calls up our JavaScript that resides at the top of the page. The function we call is exportimg();



Before we even called that function, there were a few things handled behind the scenes.
We first put in a block of code telling our application that we want to use the ESRI ArcGIS Server JavaScript API 2.1.



Next, we start a new script block and tell our application we will be using esri's dojo tools. Now the question to ask ourselves, even before writing code is; what do we want? The application wants to know the same thing. Just like a restaurant, you place your order and what you requested is prepared for you. With this information in hand, let's place our order. We need three things total and that is it. At our sit down web service, the application uses parameters, the variables that will be used to plug into our code to make it work. It's just like, if you don't order steak, you don't get steak. So, if you don't ask for a map, you won't get a map. To do this we add three declarations.






The first is our web service, displayed as dynamicMapServiceLayer. The second is the variable params which we need for the purpose of defining the output of our map image that we export. The final variable is the printMapURL. Remember the old saying about the most important thing is "location, location, location". This holds true for the printMapURL. It serves one purpose. When the map is exported, it will tell you where it went. And we need that for our PrintTask. Below is the entire script block. Don't worry, we will go through it, but take a look at the line function init() and right at the bottom of the script where you see dojo.addOnLoad(init); dojo.addOnLoad(init); will run as it does not reside in a function. Time to load the code; we define our map in the first line. In the next line, here is one of our three parameters; params. Here it defines the dpi or dots per inch for printing, the width and height of the map and the format to be exported. Define the web service in the dynamicMapServiceLayer and then add it to the map with map.addLayer. Everything is ready to enable exporting our map. We haven't talked about the printMapURL. Do I really need to say; but wait there's more? Jump down below the next block of code and keep reading.



There was a lot to talk about once we clicked that button, but I wanted you to know how everything got wired so this next piece would make more sense.
Now that we have clicked the button to call the exportimg function, it's nice to have information for our variables as we use them immediately.
The exportimg function uses the parameters that we already have and then we use the expmapimagfunc(mapimg) function to return our third variable. The printMapURL.





We use the getElementById and then set the lblMapLocation text to the URL and the image file that was exported. And finally we open the CreatePdf.aspx and append the printMapURL as a variable to pass into our new browser window. From here we leave JavaScript and move to VB.NET. Now if you want the project written in C#; you can use a free converter to do so at Developer Fusion.








Our code runs and our new browser window opens and there you have it; a pdf embedded in our web page. And we are finally at that awkward question; where do embedded pdf's come from? That's not a pdf down below, but it plays a real one on print sample site I will be sharing with you.




Our web page has already defined a pdf in this line of code below. You can use it if you just want to embed a pdf; no printing required. It just references our pdf in the pdfs folder named "Image.pdf".




But that did not create the pdf. I used a tool called iTextSharp which you can download. Many examples are written in C#, so converted C# code to VB.NET. If you have would like a C# example, just ask. Or if you have try to create a C# example and have problems, just post your question about it too.




In our Page_Load event, we define the location of the pdfs folder and variable that we want to use to print our pdf. We first defined the URL of the image as printMapURL. Once we had the value, we assigned it to sender. At the top of our web page is where that image went to.
You will notice that within the address bar after the current web page, sender was added it was set to the value of the location of the image and the image itself.
CreatePdf.aspx?sender=http://sampleserver1b.arcgisonline.com/arcgisoutput/_ags_map687a6f058c52422f9503a216b51da659.png
Finally, we create a new document and then attempt to write our our pdf in the PdWriter by creating a pdf in the pdfs folder named "Image.pdf" . Our pdf is created, but there is no image yet, so we open the new document to write on it or is this case, to add the image. To do that we look at the sender value, which is the URL of our map image; and then we add it to the pdf. Once it is written, we close the pdf and then for informational purposes only, I add the text PDF has been created. You do not need this.
And there you have it, the PrintTask for the ESRI JavaScript API 2.1 using Visual Basic .NET and the .NET Framework 4.0. Try this tool out and tell me what you think. I will be integrating, but for now; I wanted to keep it simple.
Or share a tool or make this one better.

And here is the PrintTask for the ESRI JSAPI 2.1 written in both VB.NET and C# - http://www.arcgis.com/home/item.html?id=56bc091f27134b6b9296db9ad52261a9

Other GIS Resources

For a few other examples of GIS pages in .NET, you can take a look at samples of just basic .NET Framework 3.5 maps that I created with no feature as of yet in the following API's: Microsoft Bing version 6.3,Yahoo AJAX version 3, and Google version 3. An example of Google maps in the previous version 2 as just basic html pages are at: http://sergentsolutions.net/maps.html which includes images from Flickr, an example on how GeoRSS can be applied and another at http://sergentsolutions.net/maps/testmap.html which provides you with an example on how to create tabbed balloons like below. That's all I have to share for now. What would you like to share? Your feedback is important to me. Talk to you soon.

Chris

GeoBloggers Posts You May Like

Wednesday, September 8, 2010

Web Dev Network - My Accidental International Group


Before reading this, you should be aware terms may be used that will not be explained, but the group I reference will do just that. If you want to know more about the Dev Meet Up hosted by ESRI coming to Decatur, you should read Part I.

With so many resources online, in an effort to tame the beast of information; resources have been created such as twitter, LinkedIn, Facebook and more. There have even tools to bring those resources together like Tweetdeck. But with all of the resources and integration tools that highway of information can still become a blur.

The benefit of connecting to the world allows for access to a great deal of information. Unfortunately there is a lot of bad, outdated, incorrect, and copied or you pick problems that you have run into. The negatives of increased information access will quickly become visible if you are a programmer like me. But there are other options.

Sign up for a social network account; I like to call them Pro Networks as it relates to the main purpose as to why I use them. My twitter account is basically made up of people that I follow in the field of GIS and programmers. When you want to interact with your peers, your tweet can be swept away by the tweet fleet. These are people that post so much you may miss most of the posts that you follow. Again, we narrowed the internet information, but it is still not effective. What is the best way to share information that is quality? There is a way to do that too.

People. Meet the people behind the icon. At conferences, training, and professional meetings; we have the chance to talk to our peers. There is also a chance for us to present to many at one location. So, we have a solution for acquiring good information. But where are the people in your own area and professional field. So, here we are good information without the ease of locating our peers or mass information that may be bad that makes our peers more visible. Which do you pick? By accident, it has become very clear. The one you pick is - both. We will look at that in just a moment as I will bring all of this together, but I have to add one more piece.
I am a web developer, programmer, gadget geek. If it's tech, I want to learn. But as a web developer in GIS, there is another dynamic. GIS is not all I use for my development. What happens when you go outside the scope of support for any organization? And welcome to the gray area of programming, the neutral zone of support. When support steps back, it's time for us to step up. Remember how you are told to write efficient code. How valuable is efficient support?

As a web developer and I am including mobile, we all have to resolve the issue of finding the starting line. The more you integrate, new starting lines pop up and then you stop in the middle of the race and ask; what am I supposed to do now? In web development, there is something call the separation of content, presentation and functionality. Now these three areas can actually be broken down even further. So we are now in a new area, but a very similar concept. Now we need to know all of the pieces of web development, but we also need to know the details. If you try combining this with professional interaction and are either confused or frustrated and want to stop reading - WAIT! What if there was a way to resolve these issues and someone was attempting to offer genuine help. Well I am. Now that I have gone through a few issues that you may have run into, I know there are more. But I think we can work together and knock these barriers down. Let me tell you about the Web Dev Network - My Accidental International Group.

The Web Dev Network is nothing I ever considered starting. I have a lot of ideas, good and bad alike, but this one came to me out of a series of events. And yes, Needs - Mother of Invention.

All I really wanted to do was Meet Up with my peers to discuss programming and there is one happening in the city I work. We are having a GIS Dev Meet Up. The great part about this is that it has a narrow focus to maximize content quality for GIS development and it's in my geographic areas. But there is the other issue; I think there should be more events like this in other areas. For this to ever happen, I depend on the developer community. As far as the meeting for brainstorming on code that I wanted to have, I posted it on Twitter so others in Illinois could come to the meeting. After posting, I was asked if the meeting could be online. With the idea that it could be accomplished and not necessarily having the resources, I said yes. Fortunately, USGS came to my rescue and with the help of Shelley Silch of the Geospatial Liaison for Illinois in Urbana; we had our first online meeting in May 2010. Shelley connected us from Urbana and I presented from Decatur. The meeting was live with screen sharing and "hot screen" sharing and the opportunity for the group to communicate just like you would at any meeting. Not only that. Audio and screen recordings were made for others that may not have had a chance to attend.

To announce meetings, I initially started announcing on twitter and Lone GIS Pro; a group on Google and e-mailing. If you don't have a GIS team and you want to be connected to your peers, you may be interested in Lone GIS Pro. Please let me know if you are. But as far as notifying others of meetings, I needed a better way for sharing. I joined several groups with areas of focus that I am interested in individually, but to get the word out, I started the group Web Dev Network. This would help me get the word to the attendees from several states. But I received requests to join the group from Canada and countries in Europe and Asia. With the opportunity to remove one barrier, the Web Dev Network became international. Wait a second. Now this will just become one of those groups that as it grows individuals will disappear and activity will do the same.

My goal is for the Web Dev Network to be the largest small group that facilitates sharing knowledge among professionals. This way we can become part of a group and work together to make it grow, and this should facilitate the visibility of our peers in our own geographical regions. As the group grows, it would help to have volunteers to take the lead at the various levels to maintain the local level person to person interaction. Please let me know if you are a member of the Web Dev Network and you are interested in helping. Together we can grow as small team of professionals while filling a need in the pool of knowledge with integrity.

With that, I know where I want to grow with this group. If you would like to grow this way too, please join us and we will grow together.

Thanks.

Hope to share with you soon.

Chris

Monday, September 6, 2010

GIS - Removing The Barriers Of Geography To Open The Corridors Of Knowledge

With ESRI, hosting Dev Meet Ups across the country, I wanted to share why these little events are huge opportunities. An invaluable resource that any developer can acquire is connecting with knowledgeable developers in their field. Unfortunately, there are usually barriers that prevent some developers from accessing them. But even the developers that have access to what is needed to attend events, there is another roadblock that must be addressed. Which events are the best? What event will help me grow in my field and meet others that would be of value to my gowth? There are many questions that can be asked, but the point is; nobody can go to everything and travelling can have a negative impact on the time for which anyone has to gain knowledge.

Now, we have ESRI Dev Meet Ups for the first time, and for many a barrier of meeting fellow developers and ESRI staff has been removed. Don't be too quick to dismiss such an opportunity as something that may not pertain to you or your organization as some of the good things that can be taken away from events never has been, never is, and never will be advertised. Here are a few.

I have had the opportunity to meet the founder and President of ESRI, Jack Dangermond while taking Developing ArcGIS Server Applications with the Web ADF. If you want to know how I got that chance; I will tell you my secret. I walked up to him and introduced myself. He was having lunch with someone at the campus cafeteria, but I enjoy GIS so much that this was not going to  be an excuse not to meet Jack. I am glad to have had the opportunity to meet him and I know from reputation and experience that the GIS community is very important to Jack and what we have to say. If you have the opportunity to meet him; I encourage it.

My Developing ArcGIS Server Applications with the Web ADF in .NET was taught by Rob Burke, the author of Getting to Know ArcObjects: Programming ArcObjects with VBA. He was helpful during training as well as away and I hope that you get the chance to take one of his classes as well. His presentation and knowledge add quality to the course content that can not be purchased.

During the same time period, I went to the DevSummit and met Jim Barry, ESRI EDN Manager. Well, I introduced myself to him to. I had plenty of questions and ideas. He is very interested in listening to what the developer community has to say and meeting their needs as a whole while the individual is also important, they don't take precedence over the community. And Jim will be at most of the Meet Ups. This alone is an excellent reason for all developers that can; to attend a Meet Up in their area. If you have ideas bring them and talk to Jim about them. If there is something that frustrates you or is just a concern as a developer, don't complain to the world, communicate with Jim and your fellow developers at the Meet Up.

I want to thank the City of Decatur for the opportunities that I have had for training, conferences, and other GIS events of which I have had the chance to attend. Because of these opportunities, this is the third year in a row that I have been formally recognized in the field of GIS.

In 2008,  I was the Grand Prize Winner of the ArcGIS 9.3 Release Candidate Incentive Program which allowed for me to donate the prize, an annual EDN subscription saving the city over $1,000 so that they would not need to purchase the software that I used for development.

In 2009, I was published in GIS Notes and online magazine produced by ILGISA, who is having their fall conference next month on October 20-21 2010.

And this year, ESRI asked me to provide a keynote for developers migrating from the Web ADF, an API that is being deprecated by ESRI. I will talk about migrating to the JavaScript API 2.0 and integrating JavaScript libraries, but I have developed in Silverlight as well.

I will be covering new areas that you will not see on ESRI's website including separating content, presentation, and functionality; unobtrusive JavaScript to allow for development in multiple JavaScript libraries and learn how to make the ScriptManager work with the JSAPI so you can use the AJAX Control Toolkit in the .NET Framework 4.0. In addition, I Beta tested Visual Studio 2010.

Finally, I will be sharing a new custom tool that I have created. You may have or might be using this tool, at this time, but the one I will be sharing  will remove complexity be more powerful than many like it. It will be for both C# and VB.NET in Silverlight and the JSAPI 2.0.

Don't forget while you may have started developing in these new API's, this is a good time to make a connection with developers that work in the API of your choice, allowing you to connect after the Meet Up is over when your application appears to be disconnected or simply breaks and it will.

Want to know what the new tool that I spoke about is? I plan on sharing it exclusively at the ESRI Dev Meet Up in Decatur, Illinois on September 16th! So register now and get the word out.Tweet that!

Talk to you real soon. Or do you want to hear more? If you do, check out Part II and learn about how and why the Web Dev Network was created, and why it even surprised me.

Chris