<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
Hi everybody <br>i want to ask geojson features . i have city map my
country i use geojson .But i have problem about when users click my i
want to show features about city. And i have two layer one of them
geojson the other is GML This my code block ....<br><br>OpenLayers.ProxyHost = "/gt/proxy.cgi?url=";<br> var lon = 5;<br> var lat = 44;<br> var zoom = 5;<br> var map, layer;<br><br> //function init(){<br> var bounds = new OpenLayers.Bounds(<br> -125051.196, 3967670.8507,<br> 1549596.1896, 4677667.0145<br> );<br> var options = {<br> controls: [],<br> maxExtent: bounds,<br> maxResolution: 6541.59135,<br> projection: "EPSG:23036",<br> units: 'm'<br> };<br> <br> <br> map = new OpenLayers.Map('map', options);<br> <br> map.addControl(new OpenLayers.Control.PanZoomBar({<br> position: new OpenLayers.Pixel(2,10)<br> }));<br> <br> map.addControl(new OpenLayers.Control.Navigation());<br> //map.addControl(new OpenLayers.Control.Scale($('scale')));<br> map.addControl(new OpenLayers.Control.MousePosition({element: $('location')}));<br> <br> var myStyles = new OpenLayers.StyleMap({<br> "default": new OpenLayers.Style({<br> // pointRadius: "${type}", // sized according to type attribute<br> fillColor: "#black",<br> strokeColor: "#black",<br> strokeWidth: 1,<br> graphicZIndex: 1<br> })<br> });<br> <br> var geojson_format = new OpenLayers.Format.GeoJSON();<br> var vl2 = new OpenLayers.Layer.Vector("",<br> {isBaseLayer: true,<br> styleMap: new OpenLayers.StyleMap({'default':{<br> strokeColor: "#00FF00",<br> strokeOpacity: 1,<br> strokeWidth: 1,<br> fillColor: "#FF5500",<br> fillOpacity: 0.5,<br> label : "${ad}",<br> fontSize: "8px",<br> fontFamily: "Courier New, monospace", <br> labelXOffset: "0.5",<br> labelYOffset: "0.5"<br> <br> }})<br> <br> });<br> <br> map.addLayer(vl2);<br> //Gml geliyor kardes <br> map.addLayer(new OpenLayers.Layer.Vector("GML", {<br> //isBaseLayer: False , <br> styleMap: myStyles,<br> <br> protocol: new OpenLayers.Protocol.HTTP({<br>
url:
"http://localhost:8080/geoserver/trgm/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=...&maxFeatures=5000",<br> format: new OpenLayers.Format.GML()<br> <br> }),<br> strategies: [new OpenLayers.Strategy.Fixed()]<br> }));<br> <br> var selectCtrl = new OpenLayers.Control.SelectFeature(vl2,<br> {<br> clickout: true, onSelect:onFeatureSelect }<br> );<br> <br> /*var hoverCtrl = new OpenLayers.Control.SelectFeature("",<br> {highlightOnly: true}<br> );<br> map.addControl(hoverCtrl);<br> hoverCtrl.activate();*/<br> <br> map.addControl(selectCtrl);<br> selectCtrl.activate();<br> <br> function onFeatureSelect(evt) {<br> map.zoomToExtent(evt.geometry.bounds, closest= true );<br> }<br><br> <br> var report = function(e) {<br> //OpenLayers.Console.log(e.type, e.feature.id);<br> };<br><br> function handler(request) {<br> <br> <br> vl2.addFeatures(geojson_format.read(request.responseText))<br> map.zoomToExtent(bounds);<br> }<br><br> var request = OpenLayers.Request.GET({<br>
url:
"http://localhost:8080/geoserver/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=....&maxFeatures=100&outputFormat=json&srsName=EPSG:23036",<br> params: {},<br> callback: handler<br> }); </div></body>
</html>