73602

How can i create static marker in OpenLayers 3?

Question:

I don't have a great level in javascript and OpenLayers, and i am trying to realize a map with static markers pointing airports in all the world.<br /> Well i tried to search my answer but i can't resolve my problem.

I already tried to find docs or examples, but every time it doesn't work.

Please if anybody can help me by telling me how to create markers based on a list of data?

Thank you a lot.

Answer1:

(<a href="http://jsfiddle.net/jonataswalker/vtfuqbuj/" rel="nofollow">fiddle</a>)

var vectorLayer = new ol.layer.Vector({ source: new ol.source.Vector({ format: new ol.format.GeoJSON(), url: 'url_of_your_file' }) }); map.addLayer(vectorLayer);

This way you can load a GeoJSON file into your map.

If you want, say, a circle marker you add a style to <a href="http://openlayers.org/en/master/apidoc/ol.layer.Vector.html" rel="nofollow">ol.layer.Vector</a> like:

var vectorLayer = new ol.layer.Vector({ source: new ol.source.Vector({ format: new ol.format.GeoJSON(), url: 'url_of_your_file' }), style: new ol.style.Style({ image: new ol.style.Circle({ radius: 10, fill: new ol.style.Fill({ color: '#ffff00' }) }) }) });

Recommend

  • Regex for Specific Tag
  • How can we prepend rows to a react native list-view?
  • How to use jQuery's $.post() method with async/await and typescript
  • Overlapping controls in Windows XP
  • SAVE attribute needed for Fortran variables when only the C_LOC address is returned to a C program?
  • What's the purpose of QString?
  • Zurb Foundation _global.scss meta styles for js?
  • How to run “Deployd” on port 80 instead of port 5000 in webserver.
  • Jackson Parser: ignore deserializing for type mismatch
  • Setting up SourceTree to merge unity3d scenes with UnityYAMLMerge
  • Unity3D & Android: Difference between “UnityMain” and “main” threads?
  • Does CUDA 5 support STL or THRUST inside the device code?
  • Join two tables and save into third-sql
  • How to model a transition system with SPIN
  • Javascript + PHP Encryption with pidCrypt
  • ORA-29908: missing primary invocation for ancillary operator
  • QuartzCore.framework for Mono Develop
  • R: gsub and capture
  • RestKit - RKRequestDelegate does not exist
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • Comma separated Values
  • trying to dynamically update Highchart column chart but series undefined
  • Acquiring multiple attributes from .xml file in c#
  • embed rChart in Markdown
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • Turn off referential integrity in Derby? is it possible?
  • Qt: Run a script BEFORE make
  • How can I remove ASP.NET Designer.cs files?
  • python draw pie shapes with colour filled
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]
  • Add sale price programmatically to product variations
  • Is there any way to bind data to data.frame by some index?
  • How to get NHibernate ISession to cache entity not retrieved by primary key
  • How can i traverse a binary tree from right to left in java?
  • How can I use `wmic` in a Windows PE script?
  • Unable to use reactive element in my shiny app
  • Converting MP3 duration time
  • Conditional In-Line CSS for IE and Others?
  • How to load view controller without button in storyboard?
  • How do I use LINQ to get all the Items that have a particular SubItem?