Book Image

OpenLayers 2.10 Beginner's Guide

Book Image

OpenLayers 2.10 Beginner's Guide

Overview of this book

Table of Contents (18 chapters)
OpenLayers 2.10
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for Action – adding data to your map


Time to get back to coding. Now that we have the data from Flickr from the previous example, let's add it to our map. We'll create a Google Maps base layer and then a vector layer filled with the Flickr data on top of it.

  1. First, we need to make sure the flickr_data.kml file is in the same directory that we'll be creating our map in. Save the file in your server's document root folder, which may be something like (with Xampp on windows) c:/xampp/htdocs or on OSX (with Xammp, http://www.apachefriends.org/en/xampp-macosx.html) in /Applications/XAMPP, or on Linux: /var/www/. We'll refer to it as example_1.html.

  2. Now let's create the map. We won't be using a WMS layer this time—instead, we'll just be using a Google base map and place our vector layer on top of it. Make sure to first add the reference to the Google Maps API in the <head> section:

    <script src="http://maps.google.com/maps/api/js?sensor=false"></script>
  3. Now, create and add a...