Archive

Posts Tagged ‘OpenLayers’

How Google Fusion Table made my life MUCH easier


Google Fusion Table is still in Beta. But it’s powerful! There are so many things you can do with Google Fusion Table and as far as I am concerned it has THE potential in many ways to redefine how GIS professionals mange and publish GIS data.  I am going to give you one little example to demonstrate that and show you how it made my life much easier.

What I wanted to do

Build a web map that consumes my GIS data. I wanted user be able to click on the feature on web map to get attributes of the selected feature

What I have

  • My GIS data in ESRI Shapefile
  • WMS of my data served out by GeoServer
  • Email from my department telling me that ArcGIS Server is too expensive to purchase

Issue

I built a web map with OpenLayers, and Google Map as background. It consumes WMS served out by GeoServer. When user clicks on the feature on web map, the attributes of clicked feature are displayed on the webpage below the map. This seems to be fine. But:

  1. A proxy to handle cross-site scripting problem was introduced into this web map so that when user clicks on the feature, the attributes actually show up. This is a known security risk and even though the proxy mechanism works in a test environment, my organization won’t allow this proxy thing to happen when the web page goes public
  2. I spent lots of effort to program OpenLayers, Google map, WMS and the CGI for proxy on my web page so that they work well together but in the end all these efforts are wasted because of the security risk

Solution

I tried Google Fusion Table and its a perfect way to work with in my situation.  Google Fusion Table allows you to do the following cool things:

  1. Upload spatial data in KML format
  2. Plot uploaded spatial data on Google Map
  3. When clicking on the spatial data on Google Map, you get popup of the attributes

So I use ArcGIS to convert my shapefile into KML and upload the KML into a fusion table. Once my data is in a fusion table, I clicked on Visualize -> Map to get a Google Map view.  On top of the Google Map, I can “Get embeddable link” of my data in a Google Map view. Then I use this link on my web page for the web map. See the bottom of this post for how my data looks like. Just in case you haven’t realize the huge benefit of using Google Fusion Table in my situation:

  • I don’t need a sever
  • I don’t need to program OpenLayers and WMS etc.
  • I don’t need to worry about cross site scripting security risk. Speaking of security risk, my data is not sensitive so I have no concern of data security

I highly recommend anyone who works in professional GIS arena try Google Fusion Table. It is definitely redefining how we publishing and sharing GIS data.

Make GetFeatureInfo work for WMS map

What I wanted to do:

  • Create a webpage with map using OpenLayers. The map consumes a WMS from my GeoServer
  • Get attributes of the data when I click on a feature on the map. The attributes will be displayed under the map in a table

What I have:

Issue:

  • I followed examples of GetFeatureInfo to create WMS overlay on Google map using OpenLayers. It worked well. But nothing showed up when I click feature on the map: GetFeatureInfo didn’t work

Solution:

The problem is due to JavaScript’s security restriction on cross site XMLHttpRequest (See ProxyHost section in http://trac.osgeo.org/openlayers/wiki/FrequentlyAskedQuestions). To solve this problem, I need a proxy to bypass this restriction. To follow “How do I setup ProxyHost?” in the FAQ and some other Q&As on the internet, I did the following:

  • Install Apache HTTP server on my PC
  • Get proxy.cgi from http://trac.osgeo.org/openlayers/browser/trunk/openlayers/examples/proxy.cgi
  • Change python path on the top line of proxy.cgi to my python executable (#!C:/Python26/ArcGIS10.0/python.exe -u;)
  • Add ‘localhost:8080’ in allowedHosts in proxy.cgi. This allows the proxy to work for GeoServer
  • Copy proxy.cgi to /cgi-bin under Apache folder on my PC
  • Start up Apache
  • To test the proxy.cgi, I ran http://localhost/cgi-bin/proxy.cgi, which redirected me to the homepage of OpenLayers.org
  • Copy my webpage Test.html to /htdocs under Apache folder (where I pretend I am going to serve out my webpage)
  • Add OpenLayers.ProxyHost = “/cgi-bin/proxy.cgi?url=”; on the webpage
  • Start up GeoServer
  • run the webpage from localhost/Test.html
It worked!
Categories: Web GIS Tags: , ,