Be Different with Custom Styled Google Maps

If you are developing with the Google Maps JavaScript API you’re already creating custom code so you might as well go the extra mile and change the default style of your map so it doesn’t look like every other Google map out there.

Getting a unique looking map that fits well with the style of your web page is actually really very easy. The Google API gives you the option of re-styling the existing standard map types or creating new map types containing your styles. Either way, if you are comfortable with the Google Maps JavaScript API you can put a fresh face on your map in no time.

Click here to see an example of a custom Google Map style.

For detailed instructions on how to custom style your map, you can see the Styled Maps section of the Google Map JavaScript API Developer’s guide.

If you would rather use a tool to generate your code you can use the ones listed below for free. Some of them even have pre-built styles that are ready to be plugged into your code.

Styled Map Wizard

Evoluted Style Tool

MapStylr

SnazzyMaps

Google Maps Colorizr

Custom Google Maps Style Tool

 

Efficient ArcServer Cache Management with a Staging Server

Getting a cache built can sometimes be a challenge but caching an ArcServer map service can be important if you want your web apps to display fast. Depending on the subject of your cache and what scales you cache at you can end up with tens or hundreds of gigabytes of data.

Art Tiles

In my office we cache both vector and imagery data for an entire county. We have 20 aerial mosaic data sets dating back to 1937 and several vector data sets that also cover the entire county. Caching all of this can put a real strain on a server and takes up limited server resources that can cause the server to perform poorly.

I’ve found that the best solution is to cache on a staging server and then transfer the cached tiles to a prepared production server. Here is how you can easily do the same:

  1. Create a service on your staging server.
  2. Set up caching in the Services Properties dialog.
  3. Create a service on your production server that has the same name as your staged service.
  4. Set up caching in the Services Properties dialog. From the “Tiling Scheme” drop down select “An existing cached map / image service” and navigate to the staging service. This will import all of your cache advanced setting that you defined on your staging service like scale levels.
  5. Run the Manage Map Server Cache Tiles tool to create the staged cache.
  6. Now you just want to copy your level folder (L00, L01, L02…) located in \arcgisserver\directories\arcgiscache\[your map service name]\_alllayers to the same location on your production server.

At this point your production server should have a full working cache. If you have a cache service that will need to be updated regularly you could even script the whole process and schedule it to run at night or on the weekend.

 

Better Basemap Management for the ESRI Javascript API

If you use ESRI’s Javascript API to build web maps you have probably noticed that your ability to manage base map layers is somewhat limited. You really only have three out-of-the-box alternatives:

  1. Define an ArcGIS.com basemap in the map constructor
  2. Create and fill a Basemap Gallery
  3. Switch between two basemaps with Basemap Toggle

But what if you don’t want to use an ArcGIS.com basemap, you want to use something other than thumbnail images to switch between basemaps or you have more than two basemaps to switch between? In that case, you probably need something a little more flexible.

I recently found myself in one of those situations. I wanted to be able to switch between a vector basemap and a basemap of current imagery as well as give viewers the opportunity to choose imagery as far back as the 1930s. I really didn’t want to show thumbnails for every year of imagery. Instead, it seemed to make more sense to allow selection by year from a drop down menu.

So I went ahead and built my own little version of a basemap switcher to handle different situations. To be fair, I could have used the ESRI Basemap Toggle dijit to handle the two main basemaps but I like having more control over my code than Dojo based dijits allow.

I put together a simple map to demonstrate switching multiple basemaps through various means like buttons, thumbnails and drop downs. The html markup and CSS  styling is pretty basic. We create a header as a toolbar (in this case our switcher is the only tool), a div for the map to be injected and markup for the the jQuery UI dialog box that will hold our switching controls.

Edit: FC Basson’s comment got me thinking about the code samples here being too complicated for what they were actually doing. I went back through and removed the toolbar and all jQuery UI and jQuery code. None of these added anything special to the app and since Dojo is already available to us, it should be used instead

<!doctype html>
<html lang="en">
<head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=7, IE=9, IE=10">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="translucent-black">

    <title>Custom Basemap Switcher</title>

    <script src="http://js.arcgis.com/3.7/"></script>

    <link rel="stylesheet" href="http://js.arcgis.com/3.7/js/dojo/dijit/themes/nihilo/nihilo.css">
    <link rel="stylesheet" href="http://js.arcgis.com/3.7/js/esri/css/esri.css">

    <style>
        html, body, #map
        {
            height: 100%;
            width: 100%;
            margin: 0;
            padding: 0;
            overflow: hidden;
        }

        #map
        {
            position: fixed;
        }

        #basemapButton
        {
            position: absolute;
            top: 25px;
            left: 70px;
            z-index: 100;
        }

        button
        {
            border-radius: 4px;
            background-color: #F1F1F1;
            font-size: 1em;
            color: #33A7DE;
        }

        #basemapDialog
        {
            background: white;
            display: none;
            font-size: 0.75em;
            height: 200px;
            left: 65px;
            position: absolute;
            top: 70px;
            width: 300px;
            border: 0.5px solid black;
            border-radius: 5px;
        }

            #basemapDialog ul, li
            {
                list-style: none;
                margin-top: 1em;
            }

        a img
        {
            border: 1px solid black;
        }

        a:hover img
        {
            border: 1px solid white;
        }
    </style>


</head>
<body class="container tundra">
 <button id="basemapButton" title="Open a basemap switching dialog">Switch Basemaps</button>
 <div id="map"></div>
 <div id="basemapDialog" title="Choose a Basemap">
 <ul>
 <li>
 <button id="wldImagery" title="Load the World Imagery layer as a basemap using this button">Imagery</button> Select by button</li>
 <li><a id="streetView">
 <img title="You can use an image thumbnail like this one to select a basemap" src="http://ryanrandom.com/examples/images/vegas.jpg" alt="Street Map View" height="50" width="50" />
 </a> Select by thumbnail</li>
 <li id="differentBase" title="View historical imagery as a basemap">
 <select name="bmSelect" id="bmSelect" title="Selecting a basemap from a dropdown is handy when you have many choices, like historical basemaps">
 <option value="none" selected>None Selected</option>
 <option value="topo">Topo</option>
 <option value="relief">Shaded Relief</option>
 </select> Select by dropdown
 </li>
 </ul>
 </div>
</body>
</html>

The code needed to run the switcher isn’t too complex either. You just need to create an ESRI Javascript map reference, create variable references to the basemaps you want to use then create a function that does the actual changing of the layers.  The rest of the code is just some jQuery Dojo/JavaScript to interact with the controls.

    <script>
        require([
            "esri/map",
            "esri/layers/ArcGISTiledMapServiceLayer",
            "esri/geometry/Extent",
            "dojo/dom",
            "dojo/dom-attr",
            "dojo/dom-prop",
            "dojo/on",
            "dojo/query",
            "dojo/NodeList-traverse"
        ], function (
            Map, ArcGISTiledMapServiceLayer, Extent, dom, domAttr, domProp, on, query
          ) {
            //We can set an extent like this one which takes us to Las Vegas, NV
            var initialExtent = new Extent(-115.68, 35.77, -114.75, 36.45);

            //Create an empty array to store a reference to the currently selected basemap layer
            currentBasemap = []

            map = new Map("map", {
                extent: initialExtent,
                logo: false,
                slider: true
            });

            //create references to all of your basemap layers but only add one to the map initially
            imagery = new ArcGISTiledMapServiceLayer("http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer");
            //add the current basemap layer to the currentBasemap array so you can keep track of what is active.
            currentBasemap.push(imagery);
            map.addLayer(imagery);
            //call reorderLayer on the map object and set your basemap to zero every time you change basemaps. This ensures that your basemap is always the bottom layer.
            map.reorderLayer(imagery, 0);

            street = new ArcGISTiledMapServiceLayer("http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");
            topo = new ArcGISTiledMapServiceLayer("http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer");
            relief = new ArcGISTiledMapServiceLayer("http://services.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer");

            //Opens and closes the basemap dialog using the basemaps button
            on(dom.byId("basemapButton"), "click", function () {
                if (!(dom.byId("basemapDialog").style.display == 'block')) {
                    dom.byId("basemapDialog").style.display = "block";
                } else {
                    dom.byId("basemapDialog").style.display = 'none';
                }
            });

            //This function does just what its name says and changes the layer
            function changeLayer(layerName) {
                map.removeLayer(currentBasemap[0])
                currentBasemap.length = 0;
                currentBasemap.push(layerName)
                map.addLayer(layerName)
                map.reorderLayer(layerName, 0);
            }

            //Here is where we switch the basemap using a button
            on(dom.byId("streetView"), "click", function () {
                domProp.set(query("#differentBase option")[0], "selected", true);
                changeLayer(street)
            });

            //Here is where we switch the basemap using a thumbnail image
            on(dom.byId("wldImagery"), "click", function () {
                domProp.set(query("#differentBase option")[0], "selected", true);
                changeLayer(imagery)
            });

            //Here is the code for handling changing your basemap based on a html select box dropdown.
            dom.byId("bmSelect").onchange = function () {
                var newBasemap = dom.byId("bmSelect").value

                //Default to the imagery basemap if "none Selected" is the choice in the dropdown 
                if (newBasemap === "none") {
                    changeLayer(imagery)
                } else {
                    //The following allows you to map the dropdown values with an object reference to the tiled service layers created above
                    var bmList = ({
                        "topo": topo, "relief": relief
                    })

                    //Find the selected basemap in the array above and use the associated object to add the selected theme layer to the map
                    for (var x in bmList) {
                        if (x === newBasemap) {
                            changeLayer(bmList[x])
                        }
                    }
                }
            }
        });
    </script>

You will notice in the code above that we have create an empty array called currentBasemap.  This array is the key to making the tool work. We store a reference to the currently loaded basemap here. That way we can access it, remove it’s corresponding basemap and load a reference to whatever new basemap that we want to display.

That’s all there is to it. You can get the full code from GitHub. You can also view a working example of the code.

Let me know if you have any suggestions on how to make it better.

Jump Start Your Geospatial Career with This Free E-book

It’s a great time to be a GIS professional. There are no shortages of jobs and the field keeps changing and expanding to include amazing technologies and applications. However, with increasing demand often comes increasing competition. Anyone who wants to enter the geospatial field or advance in it needs to pay attention to fast changing industry needs and make sure they are positioned to fill those needs.

The folks over at DirectionsMag.com have put together a collection of articles dealing with topics of interest to all levels of the geospatial community. It is called GIS Jobs, GISP Certification and Geospatial Careers and can be downloaded at

 

**

Update:  The following page has been removed from directionsmag.com

**

http://www.directionsmag.com/books/gis-jobs-gisp-certification-and-geospatial-careers/347075.

It is a great little PDF e-book covering things from GIS job interviews to issues surrounding certification. Have a look, it’s free.

 

Easily Export ArcGIS Attribute Table to CSV

 

For many ArcGIS users, exporting an attribute table to a .csv file or excel format file is a common part of their workflow. Unfortunately, exporting to either of these formats directly from the attribute table has never been a core functionality of ArcGIS. To overcome this you typically have had two choices: write a script using third-party libraries or use an ArcToolbox tool such as the Export Feature Attributes to ASCII Tool or the Table to Excel conversion tool. But with each of these, you have to open special tools or go through multiple steps to convert.

However, there is a little shortcut you can take to quickly export your data to .csv right from the attribute table.

  • From the table, click Export.
  • Under “Output Table” browse to the folder you want to put your .csv file in, save type as .txt and enter a name for your output making sure to leave off the ‘.txt’ from the end of the name.

If the ‘.txt’ extension is present in the name the tool will output a normal text file of your data. If, however, your name does not include the ‘.txt’ extension or if you specify .csv, then your output will be a .csv file by default.

 

Can I export directly to a .xlsx format?

There’s another handy little trick for quickly getting ArcGIS attribute table data into any Microsoft Excel data format.

    1. With your attribute table still open, click on the Table Options drop-down in the upper left corner of the table and click “Select All”.
    2. Alternatively, you can select only the rows you want to export by holding your Ctrl button while clicking the leftmost, gray box by each desired row. You can also use the Select By Attributes button at the top of the table or select features (and their corresponding table records) from the map itself. The point is, select some records to export.
    3. Now right click on any of the leftmost, gray box of any record in the table and choose “Copy Selected”.
    4. With an Excel spreadsheet already open, right-click in the uppermost left cell and click “paste”. All of your records will be pasted to the worksheet.
    5. Save your worksheet as a .xlsx file (or any file extension that Excel provides for saving) and you’re done.

It takes longer to explain the above method than it does to put it into practice. After you do it once or twice it will be very quick.

 

4 Essential Maps to Have in an Emergency

Essential Maps for Emergencies

September is National Emergency Preparedness month. Every year throughout the United States there are fires, floods, storms, earthquakes, industrial accidents and even explosions. Sometimes these situations are contained to a small locality where they are easily managed. Other times, emergencies cover large geographic areas and impact the lives of thousands of people. Maps, imagery and GIS have become increasingly important in preparation for and management of emergency situations at federal, state and local levels.

But geospatial tools in an emergency are not just for organizations like FEMA and public safety departments. Individuals have access today to numerous map resources and they could be using them as insurance in the event that a natural or man made disaster should strike in their area. Below are four maps that could give you the upper hand in such a situation.

Home Floor Plan

Every home needs an evacuation plan. A simple pencil sketch of your house will do as you really just need to show the walls and where doors are located. If you want to get more detailed you could use an online floor plan creator like Autodesk Homestyler. Homestyler lets you build detailed, multi-level, 3D floor plans of your home’s interior.

Current Printed Street Map

Google Maps are great for finding the shortest distance by road between locations. Along with other mapping applications like Bing Maps and MapQuest, Google Maps are a good first choice for routing yourself or others to safety. However, you always have to remember that in an emergency situation, Internet and/or cell reception could be disrupted. For this reason, among others, having a printed street map of the city you live in and the surrounding area is a good idea.
Street maps can often be purchased through organizations like AAA or in many gas stations located near the entrances to your city. The local chamber of commerce or visitor center often has maps for free or a low price or they can give you further advice on where to go to get a map. It is true that it is getting harder and harder to find good printed paper maps these days but they are still out there.

Safety Map

Maps are great if you know where you want to go. But in an emergency, unless you have a destination in mind of where you can find help or can meet up with loved ones, a map just shows you many ways to nowhere. At Safety-maps.orgyou can take care of the problem.
            Safety Maps is a free online tool that helps you plan for this situation. You can use it to choose a safe meeting place, print a customized map that specifies where it is, and share this map with your loved ones.
Safety-maps.org is a great site that is simple to use but serves a great purpose. Making a safety map is extremely easy. You just search for the area you live in (I used a zip code), position a green cross hair on the place designated for meeting and type a message or directions. Then you create your map and print it. You can fold several copies of the map for different people in your family so each will have one no matter where they are or what the situation.

US Road Map

Having a major roads map (or a US road atlas) can help you relocate once you are out of your local area if you need to evacuate quickly. A national level map is also handy for determining the location of disasters outside of your area. Rand McNally is one of the best known makers of quality road atlases.
There you go, four maps that could mean the difference in surviving an emergency situation. Are you prepared? Are there any you would add?

Could GIS be Killing You?

If you are a GIS professional there is a good possibility that you are slowly shaving time off your lifespan. What is this malady you might ask, and can it be prevented by moving to open source? If only it were that simple.
Several studies have shown that sitting for long periods of time can increase a person’s chances of dying from a heart attack by more than 50%. That is a scary fact that should get you thinking about what you can do to prevent it. Here are a couple of things you can do right now to reduce the risks associated with a sedentary job:
Sitting Kills
  1. Stand up! At least try to as much as possible. While the effects of sitting can be cumulative, interrupting your sitting periods can be beneficial.
  2. Use a standing desk. If you are in a work environment that will permit it, standing to do your work can make you feel better, make you burn more calories and of course and take care of the “sitting is bad” for you problem. If the cost of a standing desk is not something your employer will consider, you can always raise your monitors and keyboard with books or other objects.
  3. If you’re stuck using a regular desk you can always use a DeskCycle under the desk. This will keep your legs moving and blood circulating. Your rate of calorie burning will increase as well.
  4. Sit on an exercise ball. They are great for strengthening the lower back and you can always fall back into a couple of sit-ups when the fancy strikes.
  5. Collect GIS field data. If GPS data collection is part of your organization’s workflow, see if you can add that into your schedule a couple of times a week. You will be moving, burning calories and staying healthy.
  6. Exercise at your desk. Keeping your body in motion throughout the day goes a long way to keeping you healthy.
The lesson to take away from this is to keep moving. Regardless of you office situation there are probably things you can do to put a little motion into your day.

AFCEA Tracks Geospatial Intelligence

The Armed Forces Communications and Electronics Association (AFCEA) is a non-profit organization dedicated to serving military, government, academia and private industry. The association’s name centers on communications and electronics but under this broad umbrella are many varied disciplines and professional fields represented.

One such field is information systems technology. The April 2012 issue of SIGNAL, AFCEA’s monthly news magazine takes a closer look at geospatial information systems and their impact on today’s intelligence gathering efforts. While the articles in the current issue focus on the use of GIS for military intelligence gathering, they are useful for GIS users in all GIS communities. Developments, technologies and trends that begin at a national level often morph into public oriented applications that benefit downstream users. You can read the current issue of SIGNAL online and discover the other free tools AFCEA offers of their we site like their blog and e-newsletter.

Membership in AFCEA was once the privilege only of members of the military. Today, anyone with an interest in technology can join and take advantage of benefits like networking opportunities, educational discounts and product discounts through Dell and HP.

I have been a member of AFCEA for over four years now and consider it a top notch professional organization. Check it out and let me know what you think.

When GIS Becomes a Chore

River in Colorado

I just got back from a week-long trip to one of the last corners of Colorado without smoke filling the air. It was a great time of rock hunting, gold panning, hiking and just spending time with family.

In a typical work-week I will be on the computer for around eleven hours a day, however, throughout the entire week in Colorado I never went on a computer. On the drive back home the realization of how much I did not want to go back to it hit me.
It’s not that GIS work or following blogs and social media are not enjoyable activities because they are. The mix of logical problem solving through analysis and the creativity of cartography are hard to beat in any career field. I enjoy designing useful tools and providing engaging and helpful products for my employer. I also have a good time writing RyanRandom.com and keeping up with other blogs and Twitter.
The problem is that my job and online activites at home have become either boring and routine or overly time consuming. It is easy to fall into the routine of data maintenance at the day job which can make it seem boring or monotonous. Of course there really is data to maintain but my workplace is an environment that encourages innovation and learning. I need to capitalize on this.
When I get home I feel the need to throw myself into extra online activities (perhaps to compensate for my lack of interest at the office?). But what I usually end up doing is reading blogs more than writing them or just lurking places instead of being productive. When I do this I am wasting time that could be spent better elsewhere like with my family, learning a new skill or even getting enough rest.
So what can be done about a situation like this? I came up with the two lists below to help. The first list of five actions will be applied to my work situation. The second list of five actions are things that can be done at home to still be productive without being destructive.

On the Job:

  1. Find new angles to attack problems and try to incorporate new tools that can accomplish the task in a different way. There is no reason to be bored doing what I am doing even if some of my tasks are repetitive.
  2. Improve my cartography skills. No matter how effective your maps seem today, there is always room for improvement. There is a ton of great advice out there on improving cartography skill like GIS Cartography: A Guide to Effective Map Design by Gretchen Peterson.
  3. Start scripting and automating more with Python. Also, learn more programming languages that could make working easier and more fun.
  4. Participate more in the GIS community to gain insight and help from others.
  5. Utilize blogs and Twitter to solve more technical problems rather than stewing over them longer.

At Home:

  1. Put God and family first when I get home. The kids will only be the age they are now, right now. Spending time doing what matters most should be my priority; if it’s online, it does not matter most.
  2. Spend less time on the computer but accomplish more. Become more productive.
  3. Make goals before sitting down to work and get off the computer when done.
  4. Move slower and stop trying to do so much. You do not need to wear your body and mind out to be productive.
  5. Get more sleep and exercise.
Does anybody else suffer from work boredom and self-overwork at home? What are some of your solutions? I would love to hear them.

Why Globes Aren’t Popular But Should Be

Globes are fascinating geographic instruments. They give a proportionately accurate view of the earth allowing for a better understanding of the relationships between various land areas and water bodies.
While paper maps and on-screen digital maps can give much more detail about large scale areas of the earth, the globe gives an accurate representation of earth’s features at a very small scale. Nevertheless one rarely sees globes anymore today. Few classrooms have one to teach students about the planet they live on. Fewer still are found in homes.
There are several reasons for the disappearance of the globe from society.

Quality globes are expensive

You can pick up a fairly cheap one at WalMart or Target but to get a high quality one that will last many years and the annotation can be read clearly you might have to spend up to $150 or more.

Globes are difficult to update

World data can change. Place names and spellings do not stay the same forever. Updating a globe basically means buying a new one so the expense and effort do not always seem worth it. Some globe manufacturers offer a globe update program. These programs offer a discount if the globe you bought from them is within a certain warranty period.

Digital globes are prevalent

Google Earth can give a more versatile 3D model of the earth’s surface by serving updated data and more of it. Google Earth is free and it does not take up any room.
The question remains, are there any reasons why someone would want to still own a globe? I contend there are at least four good reasons for buying one:
1.       A tactile 3D earth is one of the best ways for someone to learn about the relationships between places on the earth. It can be difficult to conceptualize what is meant by terms like “the other side of the earth” or “the land down under”. On a globe it becomes obvious. Seeing a spherical object rotating on an axis is still a most effective learning tool.
2.       They look cool in an office or a library. Nothing says geography professional like a quality globe.
3.       Globes make it easier to understand the concepts of latitude and longitude. Lines of latitude and longitude are measured in angular degrees from the center of the earth. Understanding this is not easy on a flat paper map.
4.       Globes add a certain style to rooms. You can choose decorative globes that look vintage, modern, dark, light, large, small, nautical themed or covered with animal pictures for children. You can even find globes of the moon or ones that show constellations and glow in the dark.
Whatever your reason for buying a globe rest assured it will get used. There is just something about the things that make you want to touch them, spin them and admire them. Although they might not be the first thing one thinks about when geography is mentioned these days, globes are still a great and valuable tool for everyone.