Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • OpenLayers 2.10 Beginner's Guide
  • Toc
  • feedback
OpenLayers 2.10 Beginner's Guide

OpenLayers 2.10 Beginner's Guide

4.2 (9)
close
OpenLayers 2.10 Beginner's Guide

OpenLayers 2.10 Beginner's Guide

4.2 (9)

Overview of this book

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

Time for Action – using the Format and Strategy classes alone


Let's take a look at another example now. Here, we'll do something very similar to what we did in the first example—this time, however, we won't use the Protocol. Instead, we'll read in feature data as a JavaScript object and, using the GeoJSON Format class, read in the data. This way, this example will work without having to use a server or proxy host.

  1. Create a new page using the template in Chapter 1. We'll be doing three things here—creating some feature data in GeoJSON format, creating a vector layer, and loading the GeoJSON data into it. Let's create some basic feature data. Feel free to play around with the coordinates and amount of features here:

    var feature_data = { 
                "type": "FeatureCollection", 
                "features": [ 
                    {"type":"Feature","properties":{}, "geometry":{"type":"Point", "coordinates":[-81, 42]}}, 
                    {"type":"Feature","properties":{}, "geometry":{"type":"Point", "coordinates...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete