[OpenLayers-Users] RE Getfeature info without click

Steve.Toutant at inspq.qc.ca Steve.Toutant at inspq.qc.ca
Thu May 23 06:09:41 PDT 2013


I don't see hover: true in your code...

Have a look at this example
http://openlayers.org/dev/examples/getfeatureinfo-control.html

It expains how to use click and hover
steve




adityakumar529 <adityakumar529 at gmail.com>@lists.osgeo.org 
Envoyé par : openlayers-users-bounces at lists.osgeo.org
2013-05-23 09:04

A
openlayers-users at lists.osgeo.org
cc

Objet
Re: [OpenLayers-Users] RE  Getfeature info without click








HI Steve,
I tried bit could not make it.
Following is the code I am using
 function codeAddress() {
                 geocoder = new google.maps.Geocoder();
                 var address = document.getElementById("address").value;  
                 geocoder.geocode({ 'address': address }, function 
(results, status) {
                     if (status == google.maps.GeocoderStatus.OK){ 
                                 lonlat = results[0].geometry.location; 
                                 //alert(latlong); 
                                 var roadidPicker = new 
OpenLayers.Control.WMSGetFeatureInfo({
                                     url: 
'http://localhost:8080/geoserver/aditya/wms', 
                                     title: 'identify features on click',
                                     queryVisible: true,
                                 });
                                 roadidPicker.infoFormat = 
'application/vnd.ogc.gml';
 roadidPicker.events.register("getfeatureinfo", this, pickRoadid);
                                 map.addControl(roadidPicker);
                                 roadidPicker.activate();
                                 //map.setCenter(lonlat, 5);
                                 var lat = 
results[0].geometry.location.lat();
                                 alert(lat);
                                 var lng = 
results[0].geometry.location.lng();
                                 alert(lng);
                                 vectorLayer.removeAllFeatures();   
                                 var proj = new 
OpenLayers.Projection("EPSG:4326");
                                 var point = new 
OpenLayers.LonLat(lonlat);
                                 point.transform(proj, 
map.getProjectionObject()); 
                                 markers.clearMarkers();
                                 var size = new OpenLayers.Size(21,25);
                                 var offset = new 
OpenLayers.Pixel(-(size.w/2), -size.h);
                                 var icon = new
OpenLayers.Icon('http://www.openlayers.org/dev/img/marker.png',size,offset); 
 
                                 markers.addMarker(new 
OpenLayers.Marker(new
OpenLayers.LonLat(lng,lat).transform(WGS84, WGS84_google_mercator),icon)); 
 
                                 map.setCenter(new 
OpenLayers.LonLat(lng,lat).transform(WGS84,
WGS84_google_mercator), 20);
                                 var point1 = new 
OpenLayers.Geometry.Point(lng,lat).transform(WGS84,
WGS84_google_mercator);
                                 var feature1 =  new 
OpenLayers.Feature.Vector(point1);
                                 vectorLayer.addFeatures([feature1]);
 console.log(results[0].geometry.location);
 
 
                     }
                     else {
                                 console.log("Geocoding failed: " + 
status); 
                     }
                 });
    }
    // search ends
</script>

<script type="text/javascript">
    function pickRoadid(e) { 
                 var val = e.features[0].attributes.ward_name;
                 alert('pickRoadid');
                 alert(val);
                 //alert('ward_namehihi: '+val);
                 if (e.features && e.features.length) {
                     var ward_no = e.features[0].attributes.ward_no;
                     alert(ward_no);
                     return ward_no;
                 }
                 return val;
    }



-----
GIS Developer
India Urban Space Foundation
--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/Getfeature-info-without-click-tp5055234p5055252.html

Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
Users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130523/60374b13/attachment-0001.html>


More information about the Users mailing list