Thursday, July 24, 2008

Terrain in GeoMedia WebMap Mashup

In addition to the Satellite, street map, and hybrid map types, Google Maps also publishes a terrain map type. If you use the default GeoMedia WebMap 6.1 Publisher template to create a new Google Maps mashup, you will notice that there is no terrain button in the web page; only the Map, Satellite, Hybrid, and No Backdrop buttons are available. See the screen shot below.

To enable the display of terrain shaded relief data from Google, you need to add in the terrain map type to the Google Maps javascript code. Here are the steps to do it.
  1. Go to the GeoMedia WebMap Publisher created mashup folder, e.g. C:\GeoMediaWebMapProjects\mymashup\
  2. Change directory to the System folder.
  3. Use a text editor to open the file gm.js.
  4. Inside the text editor, locate the function initView.
  5. Look for the following lines in the function.



    objMapViewEle = document.getElementById("map");
    //testoutput("creating new custom map type");
    var tileLayers = [new GTileLayer(new GCopyrightCollection(), 0, 18)];

    var custommap = new GMapType(tileLayers, G_NORMAL_MAP.getProjection(), "No Backdrop",{errorMessage:"No Data Available"});
    //testoutput("creating GMap2");
    objMapView = new GMap2(objMapViewEle);

    objMapView.addControl(new GLargeMapControl());

    objMapView.addMapType(custommap);

    objMapView.addControl(new GMapTypeControl());

    gOverviewMapControl = new GOverviewMapControl(new GSize(150,150));
    objMapView.addControl(gOverviewMapControl);
    objMapView.addControl(new GScaleControl());


  6. Add in the following line in bold:

    objMapView.addMapType(custommap); objMapView.addMapType(G_PHYSICAL_MAP); objMapView.addControl(new GMapTypeControl());

  7. Save and close the file gm.js.
  8. Now, open up the mashup web page in an Internet browser. You should be able to see the Terrain button. Clicking on the button will display the terrain data in the map window as shown in the screen shot below.



There you go. Just remember, that the change in gm.js will be overwritten if you decide to republish the mashup again from GeoMedia WebMap Publisher.

No comments: