3

My aim is to create pin point on map and when click event on that pin point to show some details about that point (like shop name ,street name).

My point shape file is enter image description here

for rendering on the map i write bellow code.

LAYER
NAME "Siaya_towns"
DATA Siaya_towns
TYPE POINT
STATUS DEFAULT
CLASS
  COLOR 255 255 0
  OUTLINECOLOR 0 0 0
  SYMBOL "pin.png"
  SIZE 8  
END
END

I get the out put perfect.But i am not able to get the town name when we click on the pin point ...Please help me .how to achieve this.

  • Which tool do you use as a client? – Nicolas Boisteault Oct 20 '14 at 10:01
  • sorry iam new to this i am using ms4w for php – nickle Oct 20 '14 at 10:37
  • 1
    Do you want to display your layers in a web browser or a desktop client? Though whatever client you use, you need to activate the WMS getFeatureInfo service in mapserver then you can use QGIS for example to load your layer as WMS layer and use the 'identify features' tool to display a popup. You should dig more in the documentation, it is basic stuffs. – Nicolas Boisteault Oct 20 '14 at 10:44
  • can you provide some links to that.or else a basic example – nickle Oct 20 '14 at 10:46
  • 1
1

You need to activate getFeatureInfo service in mapserver.

Then you can display your layer via WMS protocol in OpenLayers for example.

And to finish you can add the WMSGetFeatureInfo control in OpenLayers. Look at the source code in this example :

<script>
OpenLayers.ProxyHost = "proxy.cgi?url=";

var map, info;

function load() {
    map = new OpenLayers.Map({
        div: "map",
        maxExtent: new OpenLayers.Bounds(143.834,-43.648,148.479,-39.573)
    });

    var political = new OpenLayers.Layer.WMS("State Boundaries",
        "http://demo.opengeo.org/geoserver/wms", 
        {'layers': 'topp:tasmania_state_boundaries', transparent: true, format: 'image/gif'},
        {isBaseLayer: true}
    );

    var roads = new OpenLayers.Layer.WMS("Roads",
        "http://demo.opengeo.org/geoserver/wms", 
        {'layers': 'topp:tasmania_roads', transparent: true, format: 'image/gif'},
        {isBaseLayer: false}
    );

    var cities = new OpenLayers.Layer.WMS("Cities",
        "http://demo.opengeo.org/geoserver/wms", 
        {'layers': 'topp:tasmania_cities', transparent: true, format: 'image/gif'},
        {isBaseLayer: false}
    );

    var water = new OpenLayers.Layer.WMS("Bodies of Water",
        "http://demo.opengeo.org/geoserver/wms", 
        {'layers': 'topp:tasmania_water_bodies', transparent: true, format: 'image/gif'},
        {isBaseLayer: false}
    );

    var highlight = new OpenLayers.Layer.Vector("Highlighted Features", {
        displayInLayerSwitcher: false, 
        isBaseLayer: false 
    });

    map.addLayers([political, roads, cities, water, highlight]); 

    info = new OpenLayers.Control.WMSGetFeatureInfo({
        url: 'http://demo.opengeo.org/geoserver/wms', 
        title: 'Identify features by clicking',
        queryVisible: true,
        eventListeners: {
            getfeatureinfo: function(event) {
                map.addPopup(new OpenLayers.Popup.FramedCloud(
                    "chicken", 
                    map.getLonLatFromPixel(event.xy),
                    null,
                    event.text,
                    null,
                    true
                ));
            }
        }
    });
    map.addControl(info);
    info.activate();

    map.addControl(new OpenLayers.Control.LayerSwitcher());
    map.zoomToMaxExtent();
}

</script>
  • i seen these when i pass my url its just shows blank page – nickle Oct 24 '14 at 8:54
  • You really have to make efforts to get you understood. Give examples or ways to reproduce your issue. – Nicolas Boisteault Oct 24 '14 at 10:32
  • here are the zip files download it once and see readme.txt once sraossinc.net:7071/mapfiles – nickle Oct 24 '14 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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