[Geojson] Jeojson Features
umut kara
umutkara1986 at hotmail.com
Wed Aug 15 06:55:21 PDT 2012
Hi everybody
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 ....
OpenLayers.ProxyHost = "/gt/proxy.cgi?url=";
var lon = 5;
var lat = 44;
var zoom = 5;
var map, layer;
//function init(){
var bounds = new OpenLayers.Bounds(
-125051.196, 3967670.8507,
1549596.1896, 4677667.0145
);
var options = {
controls: [],
maxExtent: bounds,
maxResolution: 6541.59135,
projection: "EPSG:23036",
units: 'm'
};
map = new OpenLayers.Map('map', options);
map.addControl(new OpenLayers.Control.PanZoomBar({
position: new OpenLayers.Pixel(2,10)
}));
map.addControl(new OpenLayers.Control.Navigation());
//map.addControl(new OpenLayers.Control.Scale($('scale')));
map.addControl(new OpenLayers.Control.MousePosition({element: $('location')}));
var myStyles = new OpenLayers.StyleMap({
"default": new OpenLayers.Style({
// pointRadius: "${type}", // sized according to type attribute
fillColor: "#black",
strokeColor: "#black",
strokeWidth: 1,
graphicZIndex: 1
})
});
var geojson_format = new OpenLayers.Format.GeoJSON();
var vl2 = new OpenLayers.Layer.Vector("",
{isBaseLayer: true,
styleMap: new OpenLayers.StyleMap({'default':{
strokeColor: "#00FF00",
strokeOpacity: 1,
strokeWidth: 1,
fillColor: "#FF5500",
fillOpacity: 0.5,
label : "${ad}",
fontSize: "8px",
fontFamily: "Courier New, monospace",
labelXOffset: "0.5",
labelYOffset: "0.5"
}})
});
map.addLayer(vl2);
//Gml geliyor kardes
map.addLayer(new OpenLayers.Layer.Vector("GML", {
//isBaseLayer: False ,
styleMap: myStyles,
protocol: new OpenLayers.Protocol.HTTP({
url: "http://localhost:8080/geoserver/trgm/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=trgm:ilceler&maxFeatures=5000",
format: new OpenLayers.Format.GML()
}),
strategies: [new OpenLayers.Strategy.Fixed()]
}));
var selectCtrl = new OpenLayers.Control.SelectFeature(vl2,
{
clickout: true, onSelect:onFeatureSelect }
);
/*var hoverCtrl = new OpenLayers.Control.SelectFeature("",
{highlightOnly: true}
);
map.addControl(hoverCtrl);
hoverCtrl.activate();*/
map.addControl(selectCtrl);
selectCtrl.activate();
function onFeatureSelect(evt) {
map.zoomToExtent(evt.geometry.bounds, closest= true );
}
var report = function(e) {
//OpenLayers.Console.log(e.type, e.feature.id);
};
function handler(request) {
vl2.addFeatures(geojson_format.read(request.responseText))
map.zoomToExtent(bounds);
}
var request = OpenLayers.Request.GET({
url: "http://localhost:8080/geoserver/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=trgm:iller2&maxFeatures=100&outputFormat=json&srsName=EPSG:23036",
params: {},
callback: handler
});
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.geojson.org/pipermail/geojson-geojson.org/attachments/20120815/8e9b1256/attachment.htm>
More information about the GeoJSON
mailing list