I need to create a simple hover using openlayers for worldwide airport data. I'm thinking maybe the associated address, maybe a picture in regards to the airport, ...anything really. It's just an html file with some js, nothing too crazy but I've been out of the GIS/coding game for a while.

This is the current code for the html file. As you can see, there is an associated map file. Since there are so many airports, I'm guessing you would want to put the code in the mapfile (in regards to the hover(s))

  <html xmlns="http://www.w3.org/1999/xhtml">
    <style type="text/css">
        #map {
            width: 1024px;
            height: 600px;
            border: 48px solid black;
    <script src="http://maps.google.com/maps/api/js?v=3.2&sensor=false"></script>
    <script src="OpenLayers/OpenLayers.js"></script>
    <script type="text/javascript">

        function init(){
        var map = new OpenLayers.Map('map', {
                controls: [
                    new OpenLayers.Control.Navigation(),
                    new OpenLayers.Control.PanZoomBar(),
                    new OpenLayers.Control.LayerSwitcher({'ascending':false}),
                    new OpenLayers.Control.Permalink(),
                    new OpenLayers.Control.ScaleLine(),
                    new OpenLayers.Control.Permalink('permalink'),
                    new OpenLayers.Control.MousePosition(),
                    new OpenLayers.Control.OverviewMap(),
                    new OpenLayers.Control.KeyboardDefaults()
                numZoomLevels: 14

        var layer1 = new OpenLayers.Layer.MapServer( "Airports", "", {map: '/data2/html/airports2.map', layers: ['Airports']}, {singleTile: true}  );


        // -->
  <body onload="init()">
    <div id="map"></div>

Here is the map file. Apologies in advance for a little screwed up indentation.

So I guess my main question is: do I need to be messing with the map file or just the html? I found another example where they were referencing the hover in the map file but that example was not also a straight html file...if that makes sense. I looked through the openlayers documentation but it was pretty tough to grasp.

Any input is greatly appreciated.

1 Answer 1


I think this is the very example you are looking for:


The example is using GeoServer, but the same applies for MapServer. You may just serve the data as WMS in MapServer, and on client side create a OpenLayers.Layer.WMS layers instead of OpenLayers.Layer.MapServer, then just do as the sample code does.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.