Code Monkey home page Code Monkey logo

ol-map's Introduction

OpenLayers 4.6+ wrapper for Polymer 2.

This is a Polymer 2-native wrapper for OpenLayers. It allows a simple embedding of an OpenLayers vector map into a Polymer project, adding layers to a self-hosted tile server, and adding markers on the map.

Install

bower install --save meledin/ol-map

Usage

The map will embed itself in the target webpage with as little code as

<ol-map></ol-map>

This will default to using the OSM tile servers. These are not intended for production use, so point the map to a custom tile source. The following also illustrates the default properties, which can be used to steer the map. Longitude, latitude and zoom will also notify when changed based on user panning.

<ol-map longitude=0 latitude=0 zoom=1 animate animate-duration=500>
  <ol-layer url="https://my.tileserver.net/{z}/{x}/{y}.png"></ol-layer>
</ol-map>

The wrapper currently supports the following properties on all layers:

  • zIndex
  • opacity

Adding a line

Lines are added using the and elements. A line accepts 2+ points, and will draw a fill between each of the points in turn. Each segment of the line can have its color changed using the color property of , or it can be globally set on the line. Use width and lineDash to customise the line appearance further.

<ol-line width=2 line-dash="[5]">
  <ol-point longitude=1 latitude=1></ol-point>
  <ol-point longitude=1 latitude=2 color="#FF0000"></ol-point>
</ol-line>

Any property bindingts to items within the line should cascade back to the line.

Adding a marker

Two types of markers are implemented: icons and circles.

<ol-marker-icon src="//dev.openlayers.org/img/marker.png" longitude=1 latitude=1 color="0xFF0000"></ol-marker-icon>
<ol-marker-circle longitude=1 latitude=1 radius=100 color="0xFF0000" stroke="0x00FF00" stroke-width=2></ol-marker-circle>

ol-map's People

Contributors

meledin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.