Skip to main content
Tweeted twitter.com/StackGIS/status/820918490949361664

I was trying different ways to display one country using countries.geojson file, but I unable to display.
I tried like this, but map is not displaying....

var map = new ol.Map({ layers : [ new ol.layer.Tile({ source : new ol.source.OSM() }), vector ], target : document.getElementById('map'), view : new ol.View({ center : [ 0,0 ], zoom : 4 }) }); var vector = new ol.layer.Vector({ source: new ol.source.Vector({ format: new ol.format.GeoJSON(), url: 'https://raw.githubusercontent.com/openlayers/ol3/6838fdd4c94fe80f1a3c98ca92f84cf1454e232a/examples/data/geojson/countries.geojson' }), style: function(feature, res){ if(feature.get("name") == "Germany"){ return new ol.style.Style({ stroke: new ol.style.Stroke({ color: 'red', width: 2 }) }); } } });

var map = new ol.Map({
    layers : [
        new ol.layer.Tile({
            source : new ol.source.OSM()
        }),   
        vector],
    target : document.getElementById('map'),
    view : new ol.View({
        center : [ 0,0 ],
        zoom : 4 
    })
});

var vector = new ol.layer.Vector({
    source: new ol.source.Vector({
        format: new ol.format.GeoJSON(),
        url: 'https://raw.githubusercontent.com/openlayers/ol3/6838fdd4c94fe80f1a3c98ca92f84cf1454e232a/examples/data/geojson/countries.geojson'
    }),
    style: function(feature, res){
        if(feature.get("name") == "Germany"){
            return new ol.style.Style({
                stroke: new ol.style.Stroke({
                    color: 'red',
                    width: 2
                })
            });
        }
    }
});

I was trying different ways to display one country using countries.geojson file, but I unable to display.
I tried like this, but map is not displaying....

var map = new ol.Map({ layers : [ new ol.layer.Tile({ source : new ol.source.OSM() }), vector ], target : document.getElementById('map'), view : new ol.View({ center : [ 0,0 ], zoom : 4 }) }); var vector = new ol.layer.Vector({ source: new ol.source.Vector({ format: new ol.format.GeoJSON(), url: 'https://raw.githubusercontent.com/openlayers/ol3/6838fdd4c94fe80f1a3c98ca92f84cf1454e232a/examples/data/geojson/countries.geojson' }), style: function(feature, res){ if(feature.get("name") == "Germany"){ return new ol.style.Style({ stroke: new ol.style.Stroke({ color: 'red', width: 2 }) }); } } });

I was trying different ways to display one country using countries.geojson file, but I unable to display.
I tried like this, but map is not displaying....

var map = new ol.Map({
    layers : [
        new ol.layer.Tile({
            source : new ol.source.OSM()
        }),   
        vector],
    target : document.getElementById('map'),
    view : new ol.View({
        center : [ 0,0 ],
        zoom : 4 
    })
});

var vector = new ol.layer.Vector({
    source: new ol.source.Vector({
        format: new ol.format.GeoJSON(),
        url: 'https://raw.githubusercontent.com/openlayers/ol3/6838fdd4c94fe80f1a3c98ca92f84cf1454e232a/examples/data/geojson/countries.geojson'
    }),
    style: function(feature, res){
        if(feature.get("name") == "Germany"){
            return new ol.style.Style({
                stroke: new ol.style.Stroke({
                    color: 'red',
                    width: 2
                })
            });
        }
    }
});
added 935 characters in body
Source Link

I was trying different ways to display one country using countries.geojson file, but I unable to display. can some one have complete example related to
I tried like this, but map is not displaying....

var map = new ol.Map({ layers : [ new ol.layer.Tile({ source : new ol.source.OSM() }), vector ], target : document.getElementById('map'), view : new ol.View({ center : [ 0,0 ], zoom : 4 }) }); var vector = new ol.layer.Vector({ source: new ol.source.Vector({ format: new ol.format.GeoJSON(), url: 'https://raw.githubusercontent.com/openlayers/ol3/6838fdd4c94fe80f1a3c98ca92f84cf1454e232a/examples/data/geojson/countries.geojson' }), style: function(feature, res){ if(feature.get("name") == "Germany"){ return new ol.style.Style({ stroke: new ol.style.Stroke({ color: 'red', width: 2 }) }); } } });

I was trying different ways to display one country using countries.geojson file, but I unable to display. can some one have complete example related to this.

I was trying different ways to display one country using countries.geojson file, but I unable to display.
I tried like this, but map is not displaying....

var map = new ol.Map({ layers : [ new ol.layer.Tile({ source : new ol.source.OSM() }), vector ], target : document.getElementById('map'), view : new ol.View({ center : [ 0,0 ], zoom : 4 }) }); var vector = new ol.layer.Vector({ source: new ol.source.Vector({ format: new ol.format.GeoJSON(), url: 'https://raw.githubusercontent.com/openlayers/ol3/6838fdd4c94fe80f1a3c98ca92f84cf1454e232a/examples/data/geojson/countries.geojson' }), style: function(feature, res){ if(feature.get("name") == "Germany"){ return new ol.style.Style({ stroke: new ol.style.Stroke({ color: 'red', width: 2 }) }); } } });

deleted 20 characters in body; edited title
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

How to display Displaying specific country into a map using countries.geojson file?

I was trying different ways to display one country using countries.geojson file, but I unable to display. can some one have complete example related to this. Thanks in advance.

How to display specific country into a map using countries.geojson file?

I was trying different ways to display one country using countries.geojson file, but I unable to display. can some one have complete example related to this. Thanks in advance.

Displaying specific country into map using countries.geojson file?

I was trying different ways to display one country using countries.geojson file, but I unable to display. can some one have complete example related to this.

edited title
Link
ahmadhanb
  • 41.4k
  • 5
  • 54
  • 109
Loading
Source Link
Loading