OpenLayers doesn't display US Census-based GeoJSON LayerAdd GeoJSON layer to OpenLayers 3OpenLayers3 with...

Symbolic Multivariate Distribution

What makes accurate emulation of old systems a difficult task?

Why does Mind Blank stop the Feeblemind spell?

Combinable filters

Was there a shared-world project before "Thieves World"?

The Defining Moment

Phrase for the opposite of "foolproof"

How to fry ground beef so it is well-browned

Is there really no use for MD5 anymore?

What is Niska's accent?

a sore throat vs a strep throat vs strep throat

How to stop co-workers from teasing me because I know Russian?

Why must Chinese maps be obfuscated?

Checks user level and limit the data before saving it to mongoDB

Why did C use the -> operator instead of reusing the . operator?

Lock file naming pattern

What term is being referred to with "reflected-sound-of-underground-spirits"?

How can I place the product on a social media post better?

Why does nature favour the Laplacian?

Fizzy, soft, pop and still drinks

How to write a column outside the braces in a matrix?

Apply MapThread to all but one variable

How can Republicans who favour free markets, consistently express anger when they don't like the outcome of that choice?

How did Captain America manage to do this?



OpenLayers doesn't display US Census-based GeoJSON Layer


Add GeoJSON layer to OpenLayers 3OpenLayers3 with google map local tiles serverProblem with adding GeoJSON to OpenLayers 3Display geojson on WMS images in openlayers 3MarkerCluster don't work with geojson layer in leafletIs it possible to insert an XYZ tile layer to an openlayers webmap created by qgis2web plugin?OpenLayers 4 does not display vector layer from geoJSONGeoJSON layer will not display anything in OpenLayers 3?Error loading geoJSON into map using OpenLayers v4.2.0Multiple layers from one WMTS-capabitilies source in Openlayers






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I'm getting started with OpenLayers and all was going well until I tried to use my own GeoJSON file.



I started with the Cartographic Boundary Shapefiles - Counties from the Census website, loaded it into http://www.mapshaper.org/ and exported it as a GeoJSON file. However when I use that as my source (either a straight Vector layer or as an Image layer) it doesn't display anything. No errors- just a empty window with zoom controls. I suspect it may have something to do with projections so I made it the only layer, but it didn't help.



   <script type="text/javascript">
var map = new ol.Map({
target: 'map',
layers: [
//new ol.layer.Tile({
// source: new ol.source.Stamen({layer: 'toner-lite'})
//}),
new ol.layer.Vector({
title: 'US Counties',
source: new ol.source.Vector({url: 'data/counties.geojson', format: new ol.format.GeoJSON() }),
style: new ol.style.Style({
fill: new ol.style.Fill({
color: 'blue'
}),
stroke: new ol.style.Stroke({
color: 'olive',
width: 10
})
})
})
],
view: new ol.View({
center: "center",
zoom: 1
})
});
</script>









share|improve this question
















bumped to the homepage by Community 5 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.






















    0















    I'm getting started with OpenLayers and all was going well until I tried to use my own GeoJSON file.



    I started with the Cartographic Boundary Shapefiles - Counties from the Census website, loaded it into http://www.mapshaper.org/ and exported it as a GeoJSON file. However when I use that as my source (either a straight Vector layer or as an Image layer) it doesn't display anything. No errors- just a empty window with zoom controls. I suspect it may have something to do with projections so I made it the only layer, but it didn't help.



       <script type="text/javascript">
    var map = new ol.Map({
    target: 'map',
    layers: [
    //new ol.layer.Tile({
    // source: new ol.source.Stamen({layer: 'toner-lite'})
    //}),
    new ol.layer.Vector({
    title: 'US Counties',
    source: new ol.source.Vector({url: 'data/counties.geojson', format: new ol.format.GeoJSON() }),
    style: new ol.style.Style({
    fill: new ol.style.Fill({
    color: 'blue'
    }),
    stroke: new ol.style.Stroke({
    color: 'olive',
    width: 10
    })
    })
    })
    ],
    view: new ol.View({
    center: "center",
    zoom: 1
    })
    });
    </script>









    share|improve this question
















    bumped to the homepage by Community 5 mins ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      0












      0








      0








      I'm getting started with OpenLayers and all was going well until I tried to use my own GeoJSON file.



      I started with the Cartographic Boundary Shapefiles - Counties from the Census website, loaded it into http://www.mapshaper.org/ and exported it as a GeoJSON file. However when I use that as my source (either a straight Vector layer or as an Image layer) it doesn't display anything. No errors- just a empty window with zoom controls. I suspect it may have something to do with projections so I made it the only layer, but it didn't help.



         <script type="text/javascript">
      var map = new ol.Map({
      target: 'map',
      layers: [
      //new ol.layer.Tile({
      // source: new ol.source.Stamen({layer: 'toner-lite'})
      //}),
      new ol.layer.Vector({
      title: 'US Counties',
      source: new ol.source.Vector({url: 'data/counties.geojson', format: new ol.format.GeoJSON() }),
      style: new ol.style.Style({
      fill: new ol.style.Fill({
      color: 'blue'
      }),
      stroke: new ol.style.Stroke({
      color: 'olive',
      width: 10
      })
      })
      })
      ],
      view: new ol.View({
      center: "center",
      zoom: 1
      })
      });
      </script>









      share|improve this question
















      I'm getting started with OpenLayers and all was going well until I tried to use my own GeoJSON file.



      I started with the Cartographic Boundary Shapefiles - Counties from the Census website, loaded it into http://www.mapshaper.org/ and exported it as a GeoJSON file. However when I use that as my source (either a straight Vector layer or as an Image layer) it doesn't display anything. No errors- just a empty window with zoom controls. I suspect it may have something to do with projections so I made it the only layer, but it didn't help.



         <script type="text/javascript">
      var map = new ol.Map({
      target: 'map',
      layers: [
      //new ol.layer.Tile({
      // source: new ol.source.Stamen({layer: 'toner-lite'})
      //}),
      new ol.layer.Vector({
      title: 'US Counties',
      source: new ol.source.Vector({url: 'data/counties.geojson', format: new ol.format.GeoJSON() }),
      style: new ol.style.Style({
      fill: new ol.style.Fill({
      color: 'blue'
      }),
      stroke: new ol.style.Stroke({
      color: 'olive',
      width: 10
      })
      })
      })
      ],
      view: new ol.View({
      center: "center",
      zoom: 1
      })
      });
      </script>






      javascript geojson openlayers






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited May 31 '15 at 12:39









      nagytech

      3,4481233




      3,4481233










      asked May 29 '15 at 4:30









      bhs128bhs128

      1




      1





      bumped to the homepage by Community 5 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 5 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          2 Answers
          2






          active

          oldest

          votes


















          0














          Maybe your problem is with the ol.View. There's no center: "center". It requires a coordinate. I follow your steps and made you an example:



          http://plnkr.co/edit/BUQoNo?p=preview



          The only difference is that I exported the shapefile as TopoJson which is smaller.






          share|improve this answer































            0














            There are two things may cause the problem: first, you need a local server like tomcat to get your GeoJSON file from this and solve same-origin policy issue. Second, you should define a proper projection for your GeoJSON file in the 'source' object as below:



            source: new ol.source.Vector({
            url: 'data/counties.geojson',
            format: new ol.format.GeoJSON(),
            projection: 'EPSG:3857'});





            share|improve this answer
























              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "79"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f149025%2fopenlayers-doesnt-display-us-census-based-geojson-layer%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              0














              Maybe your problem is with the ol.View. There's no center: "center". It requires a coordinate. I follow your steps and made you an example:



              http://plnkr.co/edit/BUQoNo?p=preview



              The only difference is that I exported the shapefile as TopoJson which is smaller.






              share|improve this answer




























                0














                Maybe your problem is with the ol.View. There's no center: "center". It requires a coordinate. I follow your steps and made you an example:



                http://plnkr.co/edit/BUQoNo?p=preview



                The only difference is that I exported the shapefile as TopoJson which is smaller.






                share|improve this answer


























                  0












                  0








                  0







                  Maybe your problem is with the ol.View. There's no center: "center". It requires a coordinate. I follow your steps and made you an example:



                  http://plnkr.co/edit/BUQoNo?p=preview



                  The only difference is that I exported the shapefile as TopoJson which is smaller.






                  share|improve this answer













                  Maybe your problem is with the ol.View. There's no center: "center". It requires a coordinate. I follow your steps and made you an example:



                  http://plnkr.co/edit/BUQoNo?p=preview



                  The only difference is that I exported the shapefile as TopoJson which is smaller.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered May 29 '15 at 10:55









                  Jonatas WalkerJonatas Walker

                  1,844720




                  1,844720

























                      0














                      There are two things may cause the problem: first, you need a local server like tomcat to get your GeoJSON file from this and solve same-origin policy issue. Second, you should define a proper projection for your GeoJSON file in the 'source' object as below:



                      source: new ol.source.Vector({
                      url: 'data/counties.geojson',
                      format: new ol.format.GeoJSON(),
                      projection: 'EPSG:3857'});





                      share|improve this answer




























                        0














                        There are two things may cause the problem: first, you need a local server like tomcat to get your GeoJSON file from this and solve same-origin policy issue. Second, you should define a proper projection for your GeoJSON file in the 'source' object as below:



                        source: new ol.source.Vector({
                        url: 'data/counties.geojson',
                        format: new ol.format.GeoJSON(),
                        projection: 'EPSG:3857'});





                        share|improve this answer


























                          0












                          0








                          0







                          There are two things may cause the problem: first, you need a local server like tomcat to get your GeoJSON file from this and solve same-origin policy issue. Second, you should define a proper projection for your GeoJSON file in the 'source' object as below:



                          source: new ol.source.Vector({
                          url: 'data/counties.geojson',
                          format: new ol.format.GeoJSON(),
                          projection: 'EPSG:3857'});





                          share|improve this answer













                          There are two things may cause the problem: first, you need a local server like tomcat to get your GeoJSON file from this and solve same-origin policy issue. Second, you should define a proper projection for your GeoJSON file in the 'source' object as below:



                          source: new ol.source.Vector({
                          url: 'data/counties.geojson',
                          format: new ol.format.GeoJSON(),
                          projection: 'EPSG:3857'});






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 4 '17 at 10:50









                          nasser tahaninasser tahani

                          236110




                          236110






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f149025%2fopenlayers-doesnt-display-us-census-based-geojson-layer%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Щит и меч (фильм) Содержание Названия серий | Сюжет |...

                              is 'sed' thread safeWhat should someone know about using Python scripts in the shell?Nexenta bash script uses...

                              Meter-Bus Содержание Параметры шины | Стандартизация |...