question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

display country names on a simple vl-layer-vector

See original GitHub issue

I need to have the country names on a simple vector layer:

          <vl-map :load-tiles-while-animating="true" :load-tiles-while-interacting="true">
            <vl-view :zoom.sync="zoom" :center.sync="center" :rotation.sync="rotation"></vl-view>
            <vl-layer-vector>
              <vl-style-box>
                <vl-style-stroke color="#ededf1"></vl-style-stroke>
              </vl-style-box>
              <vl-source-vector url="https://openlayers.org/en/latest/examples/data/geojson/countries.geojson"></vl-source-vector>
            </vl-layer-vector>
          </vl-map>

I need to add an extra layer? any other way to do it?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
become-ironcommented, Jun 29, 2020
<vl-layer-vector>
  <vl-source-vector :features="features" />
  <vl-style-func :factory="styleFunctionFactory" />
</vl-layer-vector>
function styleFunctionFactory () {
  const baseStyle = {
    textFontSize: 12
  }
  const cache = {}

  return (olFeature, resolution) => {
    const featureId = olFeature.getId()

    if (!cache[featureId]) {
      cache[featureId] = [createStyle({
        ...baseStyle,
        text: olFeature.get('some_text')
      })]
    }

    return cache[featureId]
  }
}
0reactions
stale[bot]commented, Aug 31, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Displaying specific country into map using countries.geojson ...
Use a ol.StyleFunction() and get the name (or any other - depending on the source) attribute of the feature. E.g.: // vector layer...
Read more >
Update country names and borders in example #12940 - GitHub
In the OpenLayers example Image Vector Layer, Cyprus, the island, appears divided to two countries, Cyprus and Northern Cyprus, ...
Read more >
World Countries - Overview
World Countries represents detailed boundaries for the countries of ... names and country code, along with continent, and display fields.
Read more >
Vector Layer - OpenLayers
The countries are loaded from a GeoJSON file. Information about countries is shown on hover and click. main.js.
Read more >
How to create a countries map with your own data
This tutorial shows how to Join MapTiler Countries with your own custom data and make a choropleth map.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found