Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I can show wms png format my map but i didnt render jeojson and gml format by the way my url is correct service. İn additonal i used same code in my local and i can render local geoserver . plz show some way ??? some code in comment line . Why firebug say openlayers protocols undefined .But when i use my local geoserver and i can edit options and url i can show map gml and geojson format in my local .But when i add service url i didnt render .But again i can render wms format . İ didnt use proxy when i work in servcice url dont remember.Thanks for advice ???? My enviroment Openlayers , Geoserver

       <!DOCTYPE html>
                    <html>
               <head>
             <script src="http://myurl.com/geoserver/openlayers/OpenLayers.js"       type="text/javascript">
       </script>


 <!--<script src="http://svn.osgeo.org/metacrs/proj4js/trunk/lib/proj4js-combined.js">   </script>-->
   <style type="text/css">

      /* General settings */

        body {
            font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
            font-size: small;
        }
        /* Toolbar styles */

            #toolbar {
            position: relative;
            padding-bottom: 0.5em;
            display: none;
        }

           #toolbar ul {
            list-style: none;
            padding: 0;
            margin: 0;
        }

        #toolbar ul li {
            float: left;
            padding-right: 1em;
            padding-bottom: 0.5em;
        }

        #toolbar ul li a {
            font-weight: bold;
            font-size: smaller;
            vertical-align: middle;
            color: black;
            text-decoration: none;
        }

        #toolbar ul li a:hover {
            text-decoration: underline;
        }

        #toolbar ul li * {
            vertical-align: middle;
        }

        /* The map and the location bar */
        #map {
            clear: both;
            position: relative;
            width: 778px;
            height: 330px;
            border: 1px solid black;
        }

        #wrapper {
            width: 778px;
        }

        #location {
            float: right;
        }

        #options {
            position: absolute;
            left: 13px;
            top: 7px;
            z-index: 3000;
        }

        /* Styles used by the default GetFeatureInfo output, added to make IE happy */
        table.featureInfo, table.featureInfo td, table.featureInfo th {
            border: 1px solid #ddd;
            border-collapse: collapse;
            margin: 0;
            padding: 0;
            font-size: 90%;
            padding: .2em .1em;
        }

        table.featureInfo th {
            padding: .2em .2em;
            text-transform: uppercase;
            font-weight: bold;
            background: #eee;
        }

        table.featureInfo td {
            background: #fff;
        }

        table.featureInfo tr.odd td {
            background: #eee;
        }

        table.featureInfo caption {
            text-align: left;
            font-size: 100%;
            font-weight: bold;
            text-transform: uppercase;
            padding: .2em .2em;
        }
    </style>

  <script defer="defer" type="text/javascript">

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(
                25.663514785385082,35.80899164217125,44.82543228354381,42.10495847294918
            );

             var options = {
                controls: [],
                maxExtent: bounds,
                maxResolution:6541.59135,
                projection: "EPSG:4326",
                units: 'm'
            };

             map = new OpenLayers.Map('map', options);

            map.addControl(new OpenLayers.Control.PanZoomBar({
                position: new OpenLayers.Pixel(2, 15)
            }));
            map.addControl(new OpenLayers.Control.Navigation());
            map.addControl(new OpenLayers.Control.Scale($('scale')));
            map.addControl(new OpenLayers.Control.MousePosition({element: $('location')}));




                    //Gml geliyor kardes 
            map.addLayer(new OpenLayers.Layer.Vector("GML", {
            isBaseLayer: true , 
            //styleMap: myStyles,

            protocol: new OpenLayers.Protocol.HTTP({
                url: "http://myurl.com/geoserver/Tarim/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=Tarim:Iller&maxFeatures=50",
                format: new OpenLayers.Format.GML()

            }),
            strategies: [new OpenLayers.Strategy.Fixed()]
        }));



         /*var geojson_format = new OpenLayers.Format.GeoJSON();
        var vl2 = new OpenLayers.Layer.Vector("",{isBaseLayer: true});
        map.addLayer(vl2);

        var selectCtrl = new OpenLayers.Control.SelectFeature(vl2,
            {
            clickout: true, onSelect:onFeatureSelect }
        );
        var hoverCtrl = new OpenLayers.Control.SelectFeature(vl2,
            {highlightOnly: true}
        );
        //map.addControl(hoverCtrl);

        //hoverCtrl.activate();

        map.addControl(selectCtrl);
        selectCtrl.activate();

        function onFeatureSelect(evt) {
            map.zoomToExtent(evt.geometry.bounds, closest=true);
        }

        //v12.events.register("featureselected", v12, selected);

        //var controlu = new OpenLayers.Control.SelectFeature(v12);

        //map.addControl(controlu);
        //controlu.activate();
        //var bounds = new OpenLayers.Control.Navigation({
        //defaultDblClick: function(event) { return; }
        //});

        //map.addControl(Navigation);


        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://my url.com/geoserver/Tarim/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=Tarim:IcmeSuyuHatti&maxFeatures=50&outputFormat=json",            
callback: handler
  });*/


    }
   </script>
  </body>
  </html>
share|improve this question
    
Here is an OpenLayers GeoJSON example: openlayers.org/dev/examples/geojson.html –  Martin Dec 24 '12 at 12:21
    
Thx martin for ur answer i know this example . –  Rusty Dec 24 '12 at 12:25
    
I solve my problem about again proxy . Dont remember guys openlayers use two proxy type one of them "/gt/proxy.cgi?url="; the other one is php proxy . İn my local i use proxy.cgi but when i use service i need php proxy .. But i dont know why :)))) –  Rusty Dec 25 '12 at 15:37
    
Please use the edit link on your question to add additional information. The Post Answer button should be used only for complete answers to the question. –  Simon Dec 26 '12 at 3:11

1 Answer 1

Well OpenLayers.Protocol undefined means that by some reason the OpenLayers library could not be downloaded into client or was not available at time it was used.

Replace your local OpenLayers copy by the site available copy during tests. After you sure all things working replace by your local version.

You have configure a proxy server also. Disable it during tests.

Remove the css part of your comments it is not relevant for solution for now. Also I could not see the tag with a call to the init function.

Did you checked for browser security blocking requests to server? Current browsers implements the CORS policy ( https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS ) for requests.

share|improve this answer
    
Thx for answer but nothing changed thx for advice i try other browser but nothing changed –  Rusty Dec 24 '12 at 20:25
    
Could you add the missing html body tag? Also looks like you using a jQuery( $ function ) library. Try a Firefox with Firebug. I guess it is the easiest to use javascript debuger. –  cavila Dec 24 '12 at 20:36
    
yes cavila . I use js library no jquery . My html tag also correct –  Rusty Dec 24 '12 at 20:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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