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 dynamic tags to your map


Let's add some more interaction to our map now. We'll add an input box that will change the requested Flickr data based on the user's input.

  1. Open up the previous example, we'll be adding to it. First, we'll need to add an input box and button to the HTML page. We'll create a div that holds them and place it right next to the map. Right after the map div, add the following:

        <div id='input_wrapper' style='position:absolute; left:610px; top:0;'> 
            <input type='text' id='input_tags' value='bird' />     
            <input type='button' id='input_submit' value='Show Data' /> 
        </div>
  2. Next, we'll need to create a function that will get called when the input_submit button is clicked. This function does three things. First, it will set the tags parameter of the vector layer to be equal to whatever value is in the input_tags input box. Secondly, it will call the vector layer's refresh() method which updates the vector...