Posts with tag javascript

Map It! - Building a MapQuest Mac OS X Dashboard Widget - Part 7 - Address Book Integration

There's nothing that makes you so aware of the improvisation of human existence as a song unfinished. Or an old address book. - Carson McCullers

In Part 1 I showed you how to get started with the MapQuest Advantage API by getting a developer key. In Part 2 I put that key to use by providing access to a basic map in the Map It! widget. Part 3 showed you how to incorporate basic geocoding. In Part 4 I discussed more advanced geocoding topics - including handling multiple matches and specifying geocode search options. Part 5 discussed adding widget options including the default zoom level, specifying point of interest icons, and the default map type. Part 6 discussed how to add direction capabilities to the widget. In this final installment I'll talk about how easy it is to integrate address searching with the Mac OS X Address Book application.

Address Book Searching

The Mac OS X Address Book application is bundled with the OS X operating system, providing a way for users to organize their contacts and associated information including their addresses. Also included with Mac OS X is an Address Book widget, which provides access to the Address Book database from a widget. I've explored the Address Book widget code, and extracted the AddressBookPlugIn. Plug-ins are native code that can be used to access operating system levels features from a widget's JavaScript interface.

Continue reading Map It! - Building a MapQuest Mac OS X Dashboard Widget - Part 7 - Address Book Integration

Zoom Levels and Image Overlays

In this post I will continue my discussion of overlays in the MapQuest JavaScript API 5.2. My last two posts covered a couple of methods for adding rollover functionality to overlays. Over the next couple of posts I will discuss some of the options that are available when working with image overlays.

There are a few things that set image overlays apart from the other overlay types. The one that poses the biggest obstacle is image resolution. Since an image overlay is "pinned" to a map with Lat and Lng coordinates, there is a significant difference in resolution required to display an image properly at different zoom levels. If this becomes an issue for your application, one of the options that is available is the setImageOverlayLevels method provided by the API.

Continue reading Zoom Levels and Image Overlays

Create a Geo File

In my previous MapQuest posts I've mostly been demonstrating how to use MapQuest to display the the various types of geo-formats (KML, GeoRSS, etc). Building on the examples of map event interaction from my previous posts, we can also build an interactive map interface where users can build their own geo-format files. Here's an example where users can interactively click on the map to create a polyline.

Continue reading Create a Geo File

Adding Rollover Functionality to Overlays: Part 2

This method, although similar to the method I covered in my last post, uses the InfoWindow of the map rather than a rollover associated with a Point Of Interest (POI). The InfoWindow is populated with the title and content when the overlay is moused-over, and follows the cursor, similar to a tooltip.

The biggest disadvantage with this method comes from the need to step outside of the API to attach a mousemove event. This means that the solution needs to take browser differences into consideration. In order to simplify the code, and because I generally use ASP.NET for most of my work, you will notice that I have utilized a few shortcuts provided by the Microsoft AJAX Library.

Continue reading Adding Rollover Functionality to Overlays: Part 2

Map It! - Building a MapQuest Mac OS X Dashboard Widget - Part 5 - Enhancing Map It!

It is not down in any map; true places never are. - Herman Melville

In Part 1 I showed you how to get started with the MapQuest Platform by getting a developer key. In Part 2, I put that key to use by providing access to a basic map in the Map It! widget. Part 3 showed you how to incorporate basic geocoding. In Part 4 I discussed more advanced geocoding topics - including handling multiple matches and specifying geocode search options. In this installment I'll discuss adding some options to the widget. Specifically I'll discuss setting the default zoom level when adding an API, specifying point of interest icons, and the default map type.

Continue reading Map It! - Building a MapQuest Mac OS X Dashboard Widget - Part 5 - Enhancing Map It!

MapNews - A Map Based News Browser - Part 3 - AOL National News RSS Feed

"In theory, there is no difference between theory and practice. But, in practice, there is." - Jan L. A. van de Snepscheut

In theory, the project to place RSS news feeds on a map could be very easy. GeoRSS is standard for encoding geographic locations in RSS feeds. RSS feeds that have this encoding are the perfect data source for this project. But, in practice, the feeds I've been looking at do not have GeoRSS information. So, I'm going to start by seeing what I can get done without GeoRSS.

The source of news that I'm working with is the AOL national news RSS feed. The description element of each feed starts with a location. I extracted the location, geocoded each location with the MapQuest (MQ) geocoding service, and then placed point of interest (POI) markers on the map.

In my last post, I laid out my design for MapNews. In this post, I present the working application and code I've written based on the MQ client Javascript tool kit. The following screen shot of MapNews shows POI markers for cities that have news stories in an example feed. I've clicked on the POI marker for Salt Lake City to expose links to news stories in the information window.

Continue reading MapNews - A Map Based News Browser - Part 3 - AOL National News RSS Feed

MapNews - A Map Based News Browser - Part 2 - Initial Design

"If you don't know where you are going, any road will get you there." - Lewis Carroll

Like many developers I often start a project by jumping in and writing code. For this project I'm going try something a little different and create a road map for my mapping project.

My project is named MapNews. In my prior post, I covered the project concept: present a map with markers/information windows which show news headlines by location.

Doing the design up front is a bit of a jump off of a cliff for me. I've had only a light reading of the MapQuest Platform documentation and am going to proceed to layout the design. This should be interesting; as the project unfolds, I'll be able to look back and see my misconceptions exposed.

Continue reading MapNews - A Map Based News Browser - Part 2 - Initial Design

Map It! - Building a MapQuest Mac OS X Dashboard Widget - Part 3 - Adding Geocoding

Somewhere there is a map of how it can be done. - Ben Stein

In Part 1 I showed you how to get started with the MapQuest Advantage API by getting a developer key. In Part 2 I put that key to use by providing access to a basic map in the Map It! widget. In this installment I'll show you how to incorporate basic geocoding.

About Geocoding

Geocoding is the process of converting an address into latitude and longitude coordinates that uniquely identify a location, and you can use to plot on a map. Applications using the MapQuest Platform can calculate the latitude and longitude of:

  • Street addresses and intersections, the highest accuracy geocoding methods.
  • Street blocks, including the nearest block to an invalid house number.
  • Postal codes, including ZIP, ZIP+2, and ZIP+4 codes.
  • City centers.
  • US state and Canadian province centers.
  • Country centers.
  • Centers of other administrative areas that are used internationally.

The Map It! application will allow users to enter an address in one of the following forms:

  • street address, zip
  • street address, city, state
  • street address, city, state, zip
  • street address, city, state, zip, country

Continue reading Map It! - Building a MapQuest Mac OS X Dashboard Widget - Part 3 - Adding Geocoding

Adding Rollover Functionality to Overlays: Part 1

Over the next couple of posts I'm going to look at the different rollover capabilities that are available for overlays in the MapQuest JavaScript API. To get started I'll post a simple module that can be imported into any application. To demonstrate, I have included links to an application that uses the module. The original Capture the Flag application can be seen here, and with the new functionality, here.

The module accomplishes two things. First, it uses the altState fields of the overlay to change the alpha value of the overlay, making it more transparent. Second, it accepts a string as an argument, using that as a title which is displayed in a rollover window. The following image is a screenshot of the Capture the Flag application, shown with the mouse hovering over the overlay on the left.

Capture The Flag Screenshot.

Continue reading Adding Rollover Functionality to Overlays: Part 1

JavaScript API 5.3RC3 Released: Traffic, Remote Collections and More!

This morning we released an update to the MapQuest JavaScript API. Version 5.3, Release Candidate 3 contains the following new functionality:

  • Drop Shadow setting for the map: We've added a visual drop-shadow graphic to the map, that you can turn on by calling map.setMapShadowState(boolean). This shadow is off by default.
  • Remote Collections: KML and GeoRSS support built into the API! Create a RemoteCollection, tell it the location of the feed and its format, and watch it get automagically sucked onto the map! If you have another format, feel free to extend the feed loading classes to create your own loadable formats.
  • Min/Max Zoom levels on POIs: You can now set minimum and maximum zoom levels on POIs. The POI would then only be visible on the map between the set zoom levels.
    poi.setValue('minZoomLevel', x) poi.setValue('maxZoomLevel', x)
  • Show Traffic Flow on the Map: You can now add traffic flow to your map. This is the first step of adding traffic functionality into the API - more will follow.
  • Show Traffic/Incident POIs on the Map: You can now add traffic incident POIs to your map. This is the second step of adding traffic functionality into the API - more will follow.

Are you starting to see a pattern here?

To use this version, change the version parameter in the API request to "v=5.3.0_RC3":
<script src="http://btilelog.access.mapquest.com/tilelog/ transaction?
transaction=script&key=YOUR_KEY_HERE&ipr=true&itk=true
&v=5.3.0_RC3" type="text/javascript"></script>

Map It! - Building a MapQuest Mac OS X Dashboard Widget - Part 2

That is the exploration that awaits you! Not mapping stars and studying nebula, but charting the unknown possibilities of existence. - Leonard Nimoy

In Part 1, I provided an overview of the MapQuest Platform, and provided instructions on how to obtain your own developer key. The developer key is required to integrate MapQuest into your application through the JavaScript API.

About Map It!

In Part 2 and 3 of building the Map It! Application, I will be creating the Mac OS X Dashboard widget shown in Figure 1.

Figure 1

Users enter an address in the search box at the top of the widget, and that point is automatically plotted and zoomed in on the map below. Users can switch between map, satellite, and hybrid views. They can also use the controls on the left to navigate and move around the map.

I've discussed building Mac OS X Dashboard widgets previously on my AOL Developer Network blog, here and here. For the Map It! Dashboard widget - I used Apple's Dashcode to jumpstart my development. Even though I used Dashcode - the techniques to integrate the MapQuest Platform, I'll review here can be utilized however you develop Dashboard Widgets.

It's important to understand that Dashboard Widgets are mini Web 2.0 applications - with their programmatic interface coming from JavaScript - so the JavaScript API is almost (I explain why it's almost in Part 3) perfect fit! All of the techniques I review in building Map It! can be used by Web 2.0 developers as well!

Adding the MapQuest JavaScript Library

In the main widget HTML page you'll need to include the following SCRIPT tag to import the JavaScript library:

<script src="http://btilelog.access.mapquest.com/tilelog/transaction?transaction=script&key=**YOUR-KEY**ipr=true&itk=true&v=5.2.0" type="text/javascript"></script>

You need to replace **YOUR-KEY** with the key that was provided in the email when you signed up for the MapQuest Platform, as discussed in Part 1.

Creating the User Interface

To place the map on the widget - you'll need to create a DIV to hold the map. In the Map It! application I created the following DIV tag.

<div id="myMap" style="width: 550px; height: 300px;"></div>

Now that you have a place to display the map, the next step is to get the map displayed in the DIV. This is simply done by create a new MQTileMap object and associating with the DIV, as shown here:

// Create a MQTileMap object and display it in the myMap DIV
myMap = new MQTileMap(document.getElementById('myMap'));

The final step is to add the Large Zoom and view controls. These controls allow the user to zoom in and out of the map, and select the type of map that is displayed (road, satellite, or hybrid). This is accomplished with the following code:

// create a new Large Zoom Control
var myLZControl = new MQLargeZoomControl(myMap);

// add it to the map at the specified offset from the Top Left corner
 myMap.addControl(myLZControl, new MQMapCornerPlacement(MQMapCorner.TOP_LEFT, new MQSize(1,1)));

// create a new View Control
var myVControl = new MQViewControl(myMap);

// add it to the map at the specified offset from the Top Right corner
myMap.addControl(myVControl, new MQMapCornerPlacement(MQMapCorner.TOP_RIGHT, new MQSize(20,20))); 

That's all that you need to add a map!

Referrers

While Dashboard widgets function just like typical Web 2.0 applications, they have two shortcomings that need to be overcome when working with the MapQuest Platform. First, when including the JavaScript library, your key maps back to the information provided when you signed up for developer access. Since Dashboard widgets run locally from your desktop they will not have a referrer. As shown in Figure 2, you'll need to add the referrer * and enable blank referrers. It's important to understand the risks of enabling blank referrers so read the Warning not carefully. Since we're not running the Dashboard widget from a web server - as all widgets are accessed locally - blank referrers are required. I'll discuss the second shortcoming with Geocoding and Mac OS X Dashboard widgets in the Part 3.

Figure 2

Conclusion

In Part 3 I'll show you how to add Geocoding to the widget to plot a point of interest based on the address entered in the search box. For your reference, here are some references to the MapQuest Platform:

Customize Your Trail Maps Using MapQuest and KML

I've always liked maps, but I've always been disappointed with the content. Sure, knowing road names and where to find a gas station is great. But I'm an outdoors kind of guy, and what I really want to see is cool biking and hiking routes. That's why I'm so excited about Keyhole Markup Language (KML) and the MapQuest Platform; the combination of the two lets users, as opposed to mapmakers, supply map content. Overlaying a map with KML data opens up many possibilities for uploading, sharing, and finding user-generated content. Couple this ability to share data with the vast number of people carrying GPS-enabled devices and you have a perfect storm for sharing off-road routes.

In this article, I show how to read KML files and create map features by using the MapQuest JavaScript API. The example I'm presenting is a KML file that describes the route for the Appalachian Trail (AT) and the location of shelters hikers use for overnight stays. I've focused on my favorite part of the trail, which is the section between Front Royal, VA, and Harper's Ferry, West Virginia. The source code for the example is listed at the end of this article. The following screen shot shows my custom AT map in action:

Continue reading Customize Your Trail Maps Using MapQuest and KML

JavaScript API Updated to 5.2.1

This morning we released an update to our JavaScript API. Version 5.2.1 uses DOJO 1.0.2, which fixes a bug in the original DOJO 0.9.0 GFX library that could cause line overlays to "jump" at certain zoom levels. If you do not use overlays in the 5.2 version of the JavaScript API, you do not need to make any changes.

To update, simply change the version parameter to "v=5.2.1":
<script src="http://btilelog.access.mapquest.com/tilelog/ transaction?
transaction=script&key=YOUR_KEY_HERE&ipr=true&itk=true& v=5.2.1" type="text/javascript"></script>

Develop Freely! Introducing: MapQuest Platform: Free Edition.

Hi! If you're reading this, you've gotten word we have this Developer Blog. A number of thoughts might be running through your mind as you hover over the "next" button on your feed reader or "close" on this browser tab:

"MapQuest has a blog?"

"MapQuest has a Developer Blog?"

"MapQuest has Developers?"

and if you're a mash-up developer: "MapQuest has APIs?"

Yeah, yeah, we know. Over the past few years we know it seemed that on the outside MapQuest seemed a bit behind the times, a Web 1.0 giant sitting on the bench of a Web 2.0 Internet. However, inside MapQuest there have been people hard at work trying to change our culture and perspective into something that can thrive in a "Web 2.0" world. We've been changing teams, processes, some developers switched to Macs -- serious, real change.

While we've been quiet, we've also been building things. More accurately, we've been rebuilding things. Starting with the 5.0 releases, we have rebuilt much of our geospatial web services platform from the ground up. Currently at version 5.2 and with 5.3 in beta, these releases contain lots of practical things, lots of cool things, lots of helpful things. Now we're making them free things.

Developer Choice

We're happy to finally introduce the MapQuest Platform: Free Edition. We've taken nearly all the features of our platform and made them freely available to developers. We believe that Free Edition provides developers a comprehensive toolset and flexible APIs so they can build well, whatever they want. Developers can choose the programming language of their choice and the features they need to build the applications they want, the way they want.

Here's some of the Free Edition features:

  • Six APIs
    • We're giving developers greater flexibility and choice by enabling them to develop in a variety of programming languages and environments, they can even mix and match:
      • Java
      • C++
      • .NET
      • JavaScript
      • AS3 (Adobe ActionScript 3: Flash, Flex, AIR)
      • Our newest API: FUJAX (Flash Under JavaScript and XML), which allows developers to write in JavaScript, yet leverage the power of Flash.
      • and of course LOLcode. Nope, sorry, still no LOLcode suport.
  • A Rich Mapping Interface for creating Rich Internet Applications with our JavaScript, AS3, or FUJAX APIs:
    • Aerial Imagery and Hybrid Views - Satellite imagery and aerial photography.
    • Smart Rollovers - Rollover windows that adapt their size and positioning on the map based on the content placed in the window.
    • Smooth Zoom - Animated transitions between zoom levels.
    • Globe View - A map of the world presented as an interactive globe.
    • "Flickable" Maps - Maps that continue to pan based on speed and friction settings.
    • Advanced Shape Overlays - Build apps that allow users to create and interact with a variety of overlays on maps.
    • Advanced Map Marker Features - With "declutter mode," automatically move collided markers (POIs) to alternate positions on the map with a customizable leader line pointing back to their original location.
  • Unlimited Maps - Worldwide: Standard or Tiled.
  • Unlimited Geocoding - Multi-line and Single-line Geocoding, Real-time Batch Geocoding, Reverse Geocoding, Postal Code and Town Geocoding.
  • Unlimited Routing - Point-to-Point, Multi-point or Optimized.
  • Simplified Data Management - MapQuest offers access to simple tools to upload and manage location information to help keep websites accurate and relevant.

You'll find more information on all of this on the MapQuest Developer Network, where you can also download the code and give the Free Edition a test drive. You can also find documentation, example applications and how-to articles to reference while checking out our APIs.

Thanks!

Capture the Flag: Using a JavaScript API to Enable Interactive Drawing in MapQuest

Introduction

The MapQuest Platform provides a powerful means for developers to integrate MapQuest technology into their web applications. In this article, I will demonstrate how to add interactive drawing to a map using the JavaScript-based API. In the resulting application, a user can set up a real-life game of Capture the Flag by drawing components of the game on an online map. You can see the application live here, and you can download the source in a .zip file here.

Continue reading Capture the Flag: Using a JavaScript API to Enable Interactive Drawing in MapQuest

Next Page >