Making Maps Without Programming

In this chapter, I’ll show you how to create online maps without any programming before we jump into programming online maps. Then I’ll show you how to use Mapbuilder.net as an example of a third-­party authoring tool for Google Maps before discussing the functionality available directly in Google Maps and Virtual Earth for making custom maps. Along the way, I’ll explain how you can transform a collection from Yahoo! Local into CSV format that you can send to Mapbuilder.net.

Mapbuilder.net

The scenario I’ll focus on in this chapter is building a map with dots pointing to a list of places for which you have addresses in the United States. We will look at more sophisticated scenarios later.

Let’s see how much of a Google map you can build without any programming. For the first two years after Google Maps was released, there was no built-­in user functionality to create custom maps. You could use the Google Maps API to create custom maps, but that’s beyond the skill or energy level of most users. Andriy Bidochko built Mapbuilder.net, a free service to let users create Google and Yahoo! Maps with custom markers through an interface that does not require knowledge of JavaScript. In this section, I’ll show you how to use Mapbuilder.net as an easy way to create your own map.

In April 2007, Google introduced the My Maps feature into its online maps. Moreover, Microsoft’s Live Search Maps has similar collection-­making functionality in its maps. That the big players have incorporated functionality that allows its end users to create maps beyond locating a single location or displaying driving directions between two points is validation of the map builder concept. I also describe how to use those functions.

What are some sites built using Mapbuilder.net? Drawing from the list of featured maps,[154][155][156][157]

Mapbuilder.net How-­To

The following are the step-­by-step instructions for how to create a map using Mapbuilder.net:

  1. Sign up for an account.[158]

  2. Click the New Map link.[159]

  3. You can create a dot in one of two ways:

    1. Start typing addresses to add (under Location Search & Quick Navigation).

    2. Click the map to indicate a spot’s location.

  4. When you add a new dot, it will be flashing. Click any marker on the map to update its information or delete it (using the Update or Delete button). Remember to hit the Add button to save the location.

  5. Use the Save Center, Zoom, MapType button located on the map to save the center of your map, zoom level, and map type (regular map, satellite, hybrid) as well. (You will have to adjust the scale and center of the map by using the zoom control and dragging the mouse to fit your taste; the default is not that helpful.)

  6. Click the Preview link (located at the upper right) to take a look at the map.

  7. To embed the map on your own site as a Google map, click the Source Code link, and copy the displayed code to your own site. (You will need to enter the appropriate API key in the code. See the “Google Maps API” section later in this chapter for how to get a key.) Note that you can use the options listed under Map Controls and Map Implementation to set other options for the map, including getting access to code to create a Yahoo! Map version of your map.

With a bit of futzing and by doing a series of searches on Yahoo! Local for addresses, I created “Some of my favorite bookstores around Berkeley,”[160]

  • “Some bookstores I like” (Google version),[161][162]

  • “Some bookstores I like” (Yahoo! version)[163]

Overall, I recommend Mapbuilder.net as a way to quickly build custom Google maps or Yahoo! maps or as a way to get started learning the APIs.[164]

Google My Maps

In addition to Mapbuilder.net, consider using Google’s built-­in My Maps functionality to create a custom Google map, which is documented here:

http://local.google.com/support/bin/answer.py?hl=en&answer=68480

I created a Google map with the same three bookstores as the previous example. I could either show the map hosted under the Google domain here:

http://maps.google.com/maps/ms?f=q&hl=en&geocode=&ie=UTF8&msa=0&msid=116029721704976049577.0000011345e68993fc0e7&z=14&om=1

or embed it elsewhere by copying and pasting HTML for an embeddable iframe to generate the following, for example:[165]

http://examples.mashupguide.net/ch13/embedded.GMap.html

There are some major advantages of using My Maps. It’s well integrated into Google Maps with its Search the Map functionality for looking up addresses and the Find Businesses option for locating businesses by name. If a marker comes up in your search results, you can click the Save to My Maps link to save the location on one of your custom maps. In addition, My Maps also lets you edit the markers and draw lines and polygons on your maps. Altogether, Google My Maps goes a long way to letting end users create custom maps (based on Google Maps, of course) without knowing JavaScript.

From a mashup point of view, you should know that you can generate a KML version of one of any of the maps produced by My Maps. The msid parameter of the Google Maps URL holds an identifier for a My Map–produced map (for example, 116029721704976049577.0000011345e68993fc0e7 for the map I produced). A URL of this format:

http://maps.google.com/maps/ms?f=q&msa=0&output=kml&msid={my-map-id}

such as the following:

http://maps.google.com/maps/ms?f=q&msa=0&output=kml&msid=116029721704976049577.0000011345e68993fc0e7

returns a KML version of the map. As I describe in greater detail later in this chapter, KML (an XML vocabulary for displaying geospatial information) lets you easily parse details of the map.

A Mashup Opportunity: Mapping Yahoo! Local Collections

Yahoo! Local makes it easy to make collections of places, but it does not allow easy mapping of those places. For instance, I assembled a collection of bookstores around Berkeley,[166]

  1. Get information out via the Yahoo! Local API.

  2. Transform the collection appropriately (XML to CSV) to feed into Mapbuilder.net.

Getting XML Out of Yahoo! Local via getCollection

We will use the getCollection method of the Yahoo! Local web service, which “enables you to get detailed information about a collection created with Yahoo! Local collections, through a REST-­like API.”[167]

The base URL is as follows:

http://collections.local.yahooapis.com/LocalSearchService/V1/getCollection

There are four parameters, as shown in Table 13-1.

Table 13.1. getCollection Parameters
Parameter Description of Parameter Value of the Parameter
appid Application ID raymondyee.net
collection_id ID of the collection to be retrieved 1000014156
output Output type Unspecified, thus returning the default of XML
callback Callback function Unspecified

In other words, we can formulate the following query:

http://collections.local.yahooapis.com/LocalSearchService/V1/getCollection?appid={app-id}&collection_id=1000014156

[Tip]Tip

You can get your Yahoo! addid at https://developer.yahoo.com/wsregapp/index.php.

This request returns the code shown in Listing 13-1.

Example 13.1. Listing 13-1.XML for a Collection from Yahoo! Local

<?xml version="1.0" encoding="UTF-8" ?>
<Result id="1000014156" xmlns="urn:yahoo:travel" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:schemaLocation="unknown">
  <Title>bookstores around Berkeley</Title>
  <Description>some of my favorite bookstores around Berkeley.</Description>
  <CreatedTime>2006-10-24 13:29:40</CreatedTime>
  <Username>Raymond Yee</Username>
  <CommentCount>0</CommentCount>
  <Item>
    <Address>
      <Address1>2476 Telegraph Ave</Address1>
      <Address2 />
      <City>Berkeley</City>
      <State>CA</State>
      <PostalCode>94704</PostalCode>
    </Address>
    <id>21518795</id>
    <Title>Moe&apos;s Books</Title>
    <CreatedTime>2006-10-24 13:29:41</CreatedTime>
    <Description>
      * The Bay Area&apos;s Largest Selection of Used Scholarly Books
    </Description>
    <Url>
http://local.yahoo.com/details?id=21518795&amp;stx=&amp;csz=Berkeley+CA&amp;ed=xoDOxa160SyYoswS6OvDhQk64pj4Q8RHG5PQhcSqprzxVT6mDHMezwfQ2U244pugG4LDSdibA78iSw--
    </Url>
    <type>Retail Shopping</type>
    <Category>Used &amp; Rare Bookstores</Category>
    <Photo />
    <Tag />
    <Phone>(510) 849-2087</Phone>
  </Item>
  <Item>
    <Address>
      <Address1>1730 4th St</Address1>
      <Address2 />
      <City>Berkeley</City>
      <State>CA</State>
      <PostalCode>94710</PostalCode>
    </Address>
    <id>21512172</id>
    <Title>Cody&apos;s Books</Title>
    <CreatedTime>2006-10-24 14:07:28</CreatedTime>
    <Description />
    <Url>
http://local.yahoo.com/details?id=21512172&amp;stx=&amp;csz=Berkeley+CA&amp;ed=3uqWba160SzFEqntYzu46yunejqBEmJnCBEi_I7QbD68sZTEVRYl4WkOGEf6alVIaEB3</Url>
    <type>Retail Shopping</type>
    <Category>Bookstores</Category>
    <Photo />
    <Tag />
    <Phone>(510) 559-9500</Phone>
  </Item>
  <Item>
    <Address>
      <Address1>6060 El Cerrito Plz</Address1>
      <Address2 />
      <City>El Cerrito</City>
      <State>CA</State>
      <PostalCode>94530</PostalCode>
    </Address>
    <id>21414999</id>
    <Title>Barnes &amp; Noble Booksellers</Title>
    <CreatedTime>2006-10-24 14:07:56</CreatedTime>
    <Description />
    <Url>
http://local.yahoo.com/details?id=21414999&amp;stx=&amp;csz=El+Cerrito+CA&amp;ed=Fo51gq160Sy24fPx_u7IvyZen3kxQq5wR9ZOi_Aos2J.pPlJ75D_th3K2MHtNCWF_V5k_n0q62ssy3I-
    </Url>
    <type>Retail Shopping</type>
    <Category>Bookstores</Category>
    <Photo />
    <Tag />
    <Phone>(510) 524-0087</Phone>
  </Item>
</Result>
               

Our goal is to convert the XML data from Listing 13-1 into CSV. There are various techniques you could consider to do this. One way is to write a PHP script that takes a collection ID and outputs CSV, as shown in Listing 13-2.[168]


With this code in hand, we can generate a CSV file that we can feed to Mapbuilder.net:

http://examples.mashupguide.net/ch13/yahooCollectionToCSV.php?cid=1000014156

To try this, we can go to our collections here:

http://local.yahoo.com/userreviews?target=p0TJ1rUjf64lpQPwpZGZmXVTOyaM&rvwtype=COLLECTION

and pull out collection ID numbers to feed to the script to generate the CSV:

Caption,"Street Address",City,State,Zip
"Moe's Books","2476 Telegraph Ave",Berkeley,CA,94704
"Cody's Books","1730 4th St",Berkeley,CA,94710
"Barnes & Noble Booksellers","6060 El Cerrito Plz","El Cerrito",CA,94530
          

We can then take the CSV and feed it to Mapbuilder.net to create our map.

[Note]Note

You might say that writing such a script gets you only CSV and you still have to manually create a map with Mapbuilder.net—and you’re right. Later, we’ll transform this collection into formats that are easier to work with in terms of generating maps.

Collection Building in Microsoft’s Live Search Maps

For Microsoft’s Live Search Maps (http://local.live.com), powered by Microsoft’s Virtual Earth, the story is a bit more complicated. Live Search Maps has excellent collection-­building facilities. I was surprised how easy it was to look up bookstores and save them to collections and then to see those bookstores on the map all within the Microsoft map environment. If you make a collection public, anyone can access it here:

http://maps.live.com/?v=2&cid={collection-id}&encType=1

For example:

http://maps.live.com/?v=2&cid=74B8FFD299EDD840!106&encType=1

Moreover, you are able to get a GeoRSS representation of a Live Search Maps collection here:

http://maps.live.com/GeoCommunity.aspx?action=retrieverss&mkt=en-us&cid={collection-id}

As you will see later in the chapter, GeoRSS is an XML vocabulary for embedding geographic information into RSS and Atom feeds. For a preview of what GeoRSS is, you can look at the following URL, which is shown in Listing 13-3.[169]

http://maps.live.com/GeoCommunity.aspx?action=retrieverss&mkt=en-us&cid=74B8FFD299EDD840!10

Example 13.3. Listing 13-3.GeoRSS of a Map from Microsoft’s Live Search Maps

<rss version="2.0" xmlns:georss="http://www.georss.org/georss"
  xmlns:gml="http://www.opengis.net/gml" 
  xmlns:Cml2GeoRssHelper="urn:Cml2GeoRssHelper">
  <channel>
    <title>Bookstores around Berkeley</title>
    <description>An example for mashupguide.net</description>
    <link>http://local.live.com/?v=2&amp;cid=74B8FFD299EDD840!106</link>
    <pubDate>Wed, 29 Aug 2007 23:32:51 GMT</pubDate>
    <item>
      <title>Moe's Books</title>
      <link>http://local.live.com/?v=2&amp;cid=74B8FFD299EDD840!106</link>
      <guid>74B8FFD299EDD840!128</guid>
      <pubDate>Wed, 29 Aug 2007 23:32:18 GMT</pubDate>
      <description>
      &lt;div style="padding:4px;"&gt; 2476 Telegraph Ave, Berkeley, CA  
      &lt;/div&gt; &lt;br/&gt;
  </description>
      <georss:point>37.865523 -122.258492</georss:point>
    </item>
    <item>
      <title>Barnes &amp; Noble Booksellers</title>
      <link>http://local.live.com/?v=2&amp;cid=74B8FFD299EDD840!106</link>
      <guid>74B8FFD299EDD840!112</guid>
      <pubDate>Sat, 06 Jan 2007 16:47:10 GMT</pubDate>
      <description>
      &lt;div style="padding:4px;"&gt; 6060 El Cerrito Plz, El Cerrito, CA 
      &lt;/div&gt; &lt;br/&gt;
  </description>
      <georss:point>37.899299 -122.300926</georss:point>
    </item>
    <item>
      <title>Cody's Books</title>
      <link>http://local.live.com/?v=2&amp;cid=74B8FFD299EDD840!106</link>
      <guid>74B8FFD299EDD840!107</guid>
      <pubDate>Wed, 25 Oct 2006 01:27:14 GMT</pubDate>
      <description>
      &lt;div style="padding:4px;"&gt; 1730 4th St, Berkeley, CA 94710 
      &lt;/div&gt; &lt;br/&gt;
  </description>
      <georss:point>37.870975 -122.301021</georss:point>
    </item>
  </channel>
</rss>
            

Notice that each of the three bookstores is now associated with a georss:point element containing the latitude and longitude of the place (georss corresponds to the http://www.georss.org/georss namespace). For example, the element for Moe’s Books is as follows:

<georss:point>37.865523 -122.258492</georss:point>

Notice a crucial difference between the GeoRSS originating from Live Search Maps and the XML of Yahoo! Local: the former contains the latitude and longitude of the bookstores, whereas the latter contains the addresses. We’ll return to studying the implications of these differences later in the chapter.

Summary of Making Maps Without Programming

What can you conclude from these exercises? Mapbuilder.net is not so easy to use if you want to create a lot of markers but you don’t already have those addresses laid out as CSV-­formatted data. It would be nice to use a service like Yahoo! Local to pull up addresses and then pass the data into Mapbuilder.net. Live.local.com is surprisingly easy to use for building maps, but it’s not easy to extract address information to create maps on competing map services. Google My Maps allows you to search for businesses and make maps of those results if you are content to make a Google map based on Google business data. Remember, however, that you can get a representation of the maps you make with Google My Maps as KML, which you can reuse elsewhere.



[162] For an explanation of how to use JavaScript injection, see http://www.mapbuilder.net/Map.Implemenation.php

[164] I ran into one snag: I wasn’t able to delete a certain point using Firefox7 on Windows XP no matter what I did. I finally deleted the point by logging in to Mapbuilder.net using Opera.