JSON Vector Overlay not showing in map

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

JSON Vector Overlay not showing in map

gingerrc4
Greetings All,

I'm trying to utilize an example from the OpenLayers website for showing map overlays.  I changed only the bounding coordinates and the data (url) location to point to where my data is stored locally.  Here is the code:
        <!DOCTYPE html>
<html>
<head>
        <title>All Overlays Example</title>
       
        <link rel="stylesheet" href="OpenLayers_2_13_1/theme/default/style.css" type="text/css" />
        <link rel="stylesheet" href="CSS/style.css" type="text/css" />
        <script src="OpenLayers_2_13_1/lib/OpenLayers.js"></script>        <script type="text/javascript"> var map; function init() { map = new OpenLayers.Map({ div: "map", allOverlays: true, maxExtent: new OpenLayers.Bounds( -121.148717, 38.502415, -119.876978, 39.067381 ) }); // give the features some style var styles = new OpenLayers.StyleMap({ "default": { strokeWidth: 2 }, "select": { strokeColor: "#0099cc", strokeWidth: 4 } }); // add rules from the above lookup table styles.addUniqueValueRules("default", "RP_TYPE", { 10: {strokeColor: "#000000", strokeWidth: 2}, 12: {strokeColor: "#222222", strokeWidth: 2}, 14: {strokeColor: "#444444", strokeWidth: 2}, 16: {strokeColor: "#666666", strokeWidth: 2}, 18: {strokeColor: "#888888", strokeWidth: 2}, 19: {strokeColor: "#666666", strokeWidth: 1} }); var vectors = new OpenLayers.Layer.Vector("Parcels", { strategies: [new OpenLayers.Strategy.Fixed()], protocol: new OpenLayers.Protocol.HTTP({ url: "Data/currprcl_to_jsonprj.json", format: new OpenLayers.Format.GeoJSON() }), styleMap: styles }); map.addLayer(vectors); map.addControl(new OpenLayers.Control.LayerSwitcher()); map.zoomToMaxExtent(); } </script>    </head>
    <body onload="init()">
       

OpenLayers Overlays Only Example

        <p id="shortdesc">
            Demonstrates a map with overlays only.
        </p>
        <div id="map" class="smallmap"></div>   
        <div id="docs">
            To create a map that allows any draw order with all layer types
            and lets you set the visibility of any layer independently, set
            the allOverlays property on the map to true.
        </div>
    </body>
</html>

Originally I was getting HTTPRequest error for Cross Origin violation but switched Chrome to allow file access from files.  Now I don't get any errors in the javascript console but I also don't see my data.  See image.  The projection is EPSG4326 and I reset the bounding coordinates to map what I was seeing in ArcMap.  Any ideas?

Thanks so much.

RG
Reply | Threaded
Open this post in threaded view
|

Re: JSON Vector Overlay not showing in map

Phil Scadden

> Originally I was getting HTTPRequest error for Cross Origin violation but
> switched Chrome to allow file access from files.  Now I don't get any errors
> in the javascript console but I also don't see my data.  See image.  The
> projection is EPSG4326 and I reset the bounding coordinates to map what I
> was seeing in ArcMap.  Any ideas?
You are showing us your HTML, but none of the relevant javascript. I am
pretty sure that JSON vector fetch is going to involve ajax, so have you
got a proxy set up? Chrome is tough on enforcing XHR. Anything useful
beyond simple map display is going to involve getting a proxy setup
properly so I would strongly suggest you try this first.


Notice: This email and any attachments are confidential.
If received in error please destroy and immediately notify us.
Do not copy or disclose the contents.

_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev
Reply | Threaded
Open this post in threaded view
|

Re: JSON Vector Overlay not showing in map

gingerrc4
Hi Phil,

Thanks for your response.  I have not set up a proxy.  I will look into this.

RG