Options
All
  • Public
  • Public/Protected
  • All
Menu

Class GeoJSONDirective<T, P>

Angular2 directive for GeoJSON of Leaflet.

You can use this directive in an Angular2 template after importing YagaModule.

How to use in a template:

<yaga-map>
    <yaga-geojson
        [(data)]="..."
        [(stroke)]="..."
        [(color)]="..."
        [(weight)]="..."
        [(opacity)]="..."
        [(lineCap)]="..."
        [(lineJoin)]="..."
        [(dashArray)]="..."
        [(dashOffset)]="..."
        [(fill)]="..."
        [(fillColor)]="..."
        [(fillOpacity)]="..."
        [(fillRule)]="..."
        [(className)]="..."
        [(lat)]="..."
        [(lng)]="..."
        [(radius)]="..."

        (add)="..."
        (remove)="..."
        (popupopen)="..."
        (popupclose)="..."
        (tooltipopen)="..."
        (tooltipclose)="..."
        (click)="..."
        (dblclick)="..."
        (mousedown)="..."
        (mouseover)="..."
        (mouseout)="..."
        (contextmenu)="..."
        (onEachFeature)="..."

        [data]="..."
        [filter]="..."
        [pointToLayer]="..."
        [styler]="..."
        [defaultStyle]="..."
        >
    </yaga-geojson>
</yaga-map>
link

http://leafletjs.com/reference-1.2.0.html#geojson Original Leaflet documentation

link

https://leaflet-ng2.yagajs.org/1.0.0-rc12/browser-test?grep=GeoJSON%20Directive Unit-Test

link

https://leaflet-ng2.yagajs.org/1.0.0-rc12/coverage/lcov-report/lib/geojson.directive.js.html Test coverage

link

https://leaflet-ng2.yagajs.org/1.0.0-rc12/typedoc/classes/geojson.directive.js.html API documentation

example

https://leaflet-ng2.yagajs.org/1.0.0-rc12/examples/geojson-directive/

Type parameters

  • T

  • P

Hierarchy

  • GeoJSON
    • GeoJSONDirective

Implements

  • OnDestroy
  • AfterContentInit

Index

Constructors

constructor

Properties

Protected _map

_map: Map

addEvent

addEvent: EventEmitter<LeafletEvent> = new EventEmitter()

From leaflet fired add event. Use it with <yaga-geojson (add)="processEvent($event)">

link

http://leafletjs.com/reference-1.2.0.html#geojson-add Original Leaflet documentation

clickEvent

clickEvent: EventEmitter<LeafletMouseEvent> = new EventEmitter()

From leaflet fired click event. Use it with <yaga-geojson (click)="processEvent($event)">

link

http://leafletjs.com/reference-1.2.0.html#geojson-click Original Leaflet documentation

contextmenuEvent

contextmenuEvent: EventEmitter<LeafletMouseEvent> = new EventEmitter()

From leaflet fired contextmenu event. Use it with <yaga-geojson (contextmenu)="processEvent($event)">

link

http://leafletjs.com/reference-1.2.0.html#geojson-contextmenu Original Leaflet documentation

dataChange

dataChange: EventEmitter<GeoJSONFeatureCollection<GeometryObject, T>> = new EventEmitter()

dblclickEvent

dblclickEvent: EventEmitter<LeafletMouseEvent> = new EventEmitter()

From leaflet fired dblclick event. Use it with <yaga-geojson (dblclick)="processEvent($event)">

link

http://leafletjs.com/reference-1.2.0.html#geojson-dblclick Original Leaflet documentation

Optional feature

feature: FeatureCollection<GeometryObject, P> | Feature<MultiPoint, P> | GeometryCollection

Protected initialized

initialized: boolean = false

Property to prevent changes before directive is initialized

mousedownEvent

mousedownEvent: EventEmitter<LeafletMouseEvent> = new EventEmitter()

From leaflet fired mousedown event. Use it with <yaga-geojson (mousedown)="processEvent($event)">

link

http://leafletjs.com/reference-1.2.0.html#geojson-mousedown Original Leaflet documentation

mouseoutEvent

mouseoutEvent: EventEmitter<LeafletMouseEvent> = new EventEmitter()

From leaflet fired mouseout event. Use it with <yaga-geojson (mouseout)="processEvent($event)">

link

http://leafletjs.com/reference-1.2.0.html#geojson-mouseout Original Leaflet documentation

mouseoverEvent

mouseoverEvent: EventEmitter<LeafletMouseEvent> = new EventEmitter()

From leaflet fired mouseover event. Use it with <yaga-geojson (mouseover)="processEvent($event)">

link

http://leafletjs.com/reference-1.2.0.html#geojson-mouseover Original Leaflet documentation

onEachFeatureEvent

onEachFeatureEvent: EventEmitter<object> = new EventEmitter()

options

options: GeoJSONOptions<P>

Protected parentLayerGroupProvider

parentLayerGroupProvider: LayerGroupProvider

popupcloseEvent

popupcloseEvent: EventEmitter<PopupEvent> = new EventEmitter()

From leaflet fired popupclose event. Use it with <yaga-geojson (popupclose)="processEvent($event)">

link

http://leafletjs.com/reference-1.2.0.html#geojson-popupclose Original Leaflet documentation

popupopenEvent

popupopenEvent: EventEmitter<PopupEvent> = new EventEmitter()

From leaflet fired popupopen event. Use it with <yaga-geojson (popupopen)="processEvent($event)">

link

http://leafletjs.com/reference-1.2.0.html#geojson-popupopen Original Leaflet documentation

removeEvent

removeEvent: EventEmitter<LeafletEvent> = new EventEmitter()

From leaflet fired remove event. Use it with <yaga-geojson (remove)="processEvent($event)">

link

http://leafletjs.com/reference-1.2.0.html#geojson-remove Original Leaflet documentation

tooltipcloseEvent

tooltipcloseEvent: EventEmitter<TooltipEvent> = new EventEmitter()

From leaflet fired tooltipclose event. Use it with <yaga-geojson (tooltipclose)="processEvent($event)">

link

http://leafletjs.com/reference-1.2.0.html#geojson-tooltipclose Original Leaflet documentation

tooltipopenEvent

tooltipopenEvent: EventEmitter<TooltipEvent> = new EventEmitter()

From leaflet fired tooltipopen event. Use it with <yaga-geojson (tooltipopen)="processEvent($event)">

link

http://leafletjs.com/reference-1.2.0.html#geojson-tooltipopen Original Leaflet documentation

Accessors

data

  • get data(): GeoJSONFeatureCollection<GeometryObject, T>
  • set data(val: GeoJSONFeatureCollection<GeometryObject, T>): void
  • Two-Way bound property for the data geoJSON data. Use it with <yaga-geojson [(data)]="someValue"> or <yaga-geojson [data]="someValue">

    Returns GeoJSONFeatureCollection<GeometryObject, T>

  • Two-Way bound property for the data geoJSON data. Use it with <yaga-geojson [(data)]="someValue"> or <yaga-geojson [data]="someValue">

    link

    http://leafletjs.com/reference-1.2.0.html#geojson-l-geojson Original Leaflet documentation

    Parameters

    • val: GeoJSONFeatureCollection<GeometryObject, T>

    Returns void

defaultStyle

  • get defaultStyle(): PathOptions
  • set defaultStyle(style: PathOptions): void
  • Input for the default style. Use it with <yaga-geojson [defaultStyle]="someValue">

    Note: Leaflet does not provide a default style, it just provides a style function!

    Returns PathOptions

  • Input for the default style. Use it with <yaga-geojson [defaultStyle]="someValue">

    Note: Leaflet does not provide a default style, it just provides a style function!

    Parameters

    • style: PathOptions

    Returns void

filter

pointToLayer

styler

  • Input for the styler function. Use it with <yaga-geojson [styler]="someValue">

    Note: The function can follow the IGeoJSONStylerFn interface. It enhances the leaflet ones with the default style as second parameter

    Returns IGeoJSONStylerFn<T> | undefined

  • Input for the styler function. Use it with <yaga-geojson [styler]="someValue">

    Note: The function can follow the IGeoJSONStylerFn interface. It enhances the leaflet ones with the default style as second parameter

    link

    http://leafletjs.com/reference-1.2.0.html#geojson-style Original Leaflet documentation

    Parameters

    Returns void

Methods

addData

  • addData(data: GeoJSONFeature<GeometryObject, T>): Layer

addEventListener

  • addEventListener(type: string, fn: LeafletEventHandlerFn, context?: any): this
  • addEventListener(eventMap: LeafletEventHandlerFnMap): this
  • Alias for on(...)

    Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

    Parameters

    • type: string
    • fn: LeafletEventHandlerFn
    • Optional context: any

    Returns this

  • Alias for on(...)

    Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

    Parameters

    • eventMap: LeafletEventHandlerFnMap

    Returns this

addEventParent

  • addEventParent(obj: Evented): this
  • Adds an event parent - an Evented that will receive propagated events

    Parameters

    • obj: Evented

    Returns this

addLayer

  • addLayer(layer: Layer): this
  • Adds the given layer to the group.

    Parameters

    • layer: Layer

    Returns this

addOneTimeEventListener

  • addOneTimeEventListener(type: string, fn: LeafletEventHandlerFn, context?: any): this
  • addOneTimeEventListener(eventMap: LeafletEventHandlerFnMap): this
  • Alias for once(...)

    Behaves as on(...), except the listener will only get fired once and then removed.

    Parameters

    • type: string
    • fn: LeafletEventHandlerFn
    • Optional context: any

    Returns this

  • Alias for once(...)

    Behaves as on(...), except the listener will only get fired once and then removed.

    Parameters

    • eventMap: LeafletEventHandlerFnMap

    Returns this

addTo

  • addTo(map: Map | LayerGroup): this
  • Parameters

    • map: Map | LayerGroup

    Returns this

Optional beforeAdd

  • beforeAdd(map: Map): this
  • Parameters

    • map: Map

    Returns this

bindPopup

  • bindPopup(content: function | Content | Popup, options?: PopupOptions): this
  • Parameters

    • content: function | Content | Popup
    • Optional options: PopupOptions

    Returns this

bindTooltip

  • bindTooltip(content: function | Tooltip | Content, options?: TooltipOptions): this
  • Parameters

    • content: function | Tooltip | Content
    • Optional options: TooltipOptions

    Returns this

bringToBack

  • bringToBack(): this
  • Brings the layer group to the top [sic] of all other layers

    Returns this

bringToFront

  • bringToFront(): this
  • Brings the layer group to the top of all other layers

    Returns this

clearAllEventListeners

  • clearAllEventListeners(): this
  • Alias for off()

    Removes all listeners to all events on the object.

    Returns this

clearLayers

  • clearLayers(): this

closePopup

  • closePopup(): this
  • Returns this

closeTooltip

  • closeTooltip(): this
  • Returns this

eachLayer

  • eachLayer(fn: function, context?: any): this
  • Iterates over the layers of the group, optionally specifying context of the iterator function.

    Parameters

    • fn: function
        • (layer: Layer): void
        • Parameters

          • layer: Layer

          Returns void

    • Optional context: any

    Returns this

fire

  • fire(type: string, data?: any, propagate?: undefined | true | false): this
  • Fires an event of the specified type. You can optionally provide a data object — the first argument of the listener function will contain its properties. The event might can optionally be propagated to event parents.

    Parameters

    • type: string
    • Optional data: any
    • Optional propagate: undefined | true | false

    Returns this

fireEvent

  • fireEvent(type: string, data?: any, propagate?: undefined | true | false): this
  • Alias for fire(...)

    Fires an event of the specified type. You can optionally provide a data object — the first argument of the listener function will contain its properties. The event might can optionally be propagated to event parents.

    Parameters

    • type: string
    • Optional data: any
    • Optional propagate: undefined | true | false

    Returns this

Optional getAttribution

  • getAttribution(): string | null
  • Returns string | null

getBounds

  • getBounds(): LatLngBounds
  • Returns the LatLngBounds of the Feature Group (created from bounds and coordinates of its children).

    Returns LatLngBounds

Optional getEvents

  • getEvents(): object
  • Returns object

    • [name: string]: function
        • (event: LeafletEvent): void
        • Parameters

          • event: LeafletEvent

          Returns void

getLayer

  • getLayer(id: number): Layer | undefined
  • Returns the layer with the given internal ID.

    Parameters

    • id: number

    Returns Layer | undefined

getLayerId

  • getLayerId(layer: Layer): number
  • Returns the internal ID for a layer

    Parameters

    • layer: Layer

    Returns number

getLayers

  • getLayers(): Layer[]
  • Returns an array of all the layers added to the group.

    Returns Layer[]

getPane

  • getPane(name?: undefined | string): HTMLElement | undefined
  • Parameters

    • Optional name: undefined | string

    Returns HTMLElement | undefined

getPopup

  • getPopup(): Popup | undefined
  • Returns Popup | undefined

getTooltip

  • getTooltip(): Tooltip | undefined
  • Returns Tooltip | undefined

hasEventListeners

  • hasEventListeners(type: string): boolean
  • Alias for listens(...)

    Returns true if a particular event type has any listeners attached to it.

    Parameters

    • type: string

    Returns boolean

hasLayer

  • hasLayer(layer: Layer): boolean
  • Returns true if the given layer is currently added to the group.

    Parameters

    • layer: Layer

    Returns boolean

invoke

  • invoke(methodName: string, ...params: any[]): this
  • Calls methodName on every layer contained in this group, passing any additional parameters. Has no effect if the layers contained do not implement methodName.

    Parameters

    • methodName: string
    • Rest ...params: any[]

    Returns this

isPopupOpen

  • isPopupOpen(): boolean
  • Returns boolean

isTooltipOpen

  • isTooltipOpen(): boolean
  • Returns boolean

listens

  • listens(type: string): boolean
  • Returns true if a particular event type has any listeners attached to it.

    Parameters

    • type: string

    Returns boolean

ngAfterContentInit

  • ngAfterContentInit(): void
  • Internal method that provides the initialization of the child popup or tooltip

    Returns void

ngOnDestroy

  • ngOnDestroy(): void
  • Internal method to provide the removal of the layer in Leaflet, when removing it from the Angular template

    Returns void

off

  • off(type: string, fn?: LeafletEventHandlerFn, context?: any): this
  • off(eventMap: LeafletEventHandlerFnMap): this
  • off(): this
  • Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

    Parameters

    • type: string
    • Optional fn: LeafletEventHandlerFn
    • Optional context: any

    Returns this

  • Removes a set of type/listener pairs.

    Parameters

    • eventMap: LeafletEventHandlerFnMap

    Returns this

  • Removes all listeners to all events on the object.

    Returns this

on

  • on(type: string, fn: LeafletEventHandlerFn, context?: any): this
  • on(eventMap: LeafletEventHandlerFnMap): this
  • Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

    Parameters

    • type: string
    • fn: LeafletEventHandlerFn
    • Optional context: any

    Returns this

  • Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

    Parameters

    • eventMap: LeafletEventHandlerFnMap

    Returns this

onAdd

  • onAdd(map: Map): this
  • Parameters

    • map: Map

    Returns this

onRemove

  • onRemove(map: Map): this
  • Parameters

    • map: Map

    Returns this

once

  • once(type: string, fn: LeafletEventHandlerFn, context?: any): this
  • once(eventMap: LeafletEventHandlerFnMap): this
  • Behaves as on(...), except the listener will only get fired once and then removed.

    Parameters

    • type: string
    • fn: LeafletEventHandlerFn
    • Optional context: any

    Returns this

  • Behaves as on(...), except the listener will only get fired once and then removed.

    Parameters

    • eventMap: LeafletEventHandlerFnMap

    Returns this

openPopup

  • openPopup(latlng?: LatLngExpression): this
  • Parameters

    • Optional latlng: LatLngExpression

    Returns this

openTooltip

  • openTooltip(latlng?: LatLngExpression): this
  • Parameters

    • Optional latlng: LatLngExpression

    Returns this

Protected redraw

  • redraw(): void

remove

  • remove(): this
  • Returns this

removeEventListener

  • removeEventListener(type: string, fn: LeafletEventHandlerFn, context?: any): this
  • removeEventListener(eventMap: LeafletEventHandlerFnMap): this
  • Alias for off(...)

    Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

    Parameters

    • type: string
    • fn: LeafletEventHandlerFn
    • Optional context: any

    Returns this

  • Alias for off(...)

    Removes a set of type/listener pairs.

    Parameters

    • eventMap: LeafletEventHandlerFnMap

    Returns this

removeEventParent

  • removeEventParent(obj: Evented): this
  • Removes an event parent, so it will stop receiving propagated events

    Parameters

    • obj: Evented

    Returns this

removeFrom

  • removeFrom(map: Map): this
  • Parameters

    • map: Map

    Returns this

removeLayer

  • removeLayer(layer: number | Layer): this
  • Removes the layer with the given internal ID or the given layer from the group.

    Parameters

    • layer: number | Layer

    Returns this

resetStyle

  • resetStyle(layer: Layer): Layer
  • Resets the given vector layer's style to the original GeoJSON style, useful for resetting style after hover events.

    Parameters

    • layer: Layer

    Returns Layer

setData

  • setData(val: GeoJSONFeatureCollection<GeometryObject, T>): this
  • Method to remove all existing data and add the new data in one step.

    Note: this is a combination of clearLayers and addData

    Parameters

    • val: GeoJSONFeatureCollection<GeometryObject, T>

    Returns this

setPopupContent

  • setPopupContent(content: Content | Popup): this
  • Parameters

    • content: Content | Popup

    Returns this

setStyle

  • setStyle(style: PathOptions): this
  • Sets the given path options to each layer of the group that has a setStyle method.

    Parameters

    • style: PathOptions

    Returns this

setTooltipContent

  • setTooltipContent(content: Content | Tooltip): this
  • Parameters

    • content: Content | Tooltip

    Returns this

setZIndex

  • setZIndex(zIndex: number): this
  • Calls setZIndex on every layer contained in this group, passing the z-index.

    Parameters

    • zIndex: number

    Returns this

toGeoJSON

  • toGeoJSON(): FeatureCollection<GeometryObject, P> | Feature<MultiPoint, P> | GeometryCollection
  • Returns a GeoJSON representation of the layer group (as a GeoJSON GeometryCollection, GeoJSONFeatureCollection or Multipoint).

    Returns FeatureCollection<GeometryObject, P> | Feature<MultiPoint, P> | GeometryCollection

togglePopup

  • togglePopup(): this
  • Returns this

toggleTooltip

  • toggleTooltip(): this
  • Returns this

unbindPopup

  • unbindPopup(): this
  • Returns this

unbindTooltip

  • unbindTooltip(): this
  • Returns this

Static addInitHook

  • addInitHook(initHookFn: function): any
  • Parameters

    • initHookFn: function
        • (): void
        • Returns void

    Returns any

Static asFeature

  • asFeature<P>(geojson: Feature<GeometryObject, P> | GeometryObject): Feature<GeometryObject, P>
  • Normalize GeoJSON geometries/features into GeoJSON features.

    Type parameters

    • P

    Parameters

    • geojson: Feature<GeometryObject, P> | GeometryObject

    Returns Feature<GeometryObject, P>

Static coordsToLatLng

  • coordsToLatLng(coords: [number, number] | [number, number, number]): LatLng
  • Creates a LatLng object from an array of 2 numbers (longitude, latitude) or 3 numbers (longitude, latitude, altitude) used in GeoJSON for points.

    Parameters

    • coords: [number, number] | [number, number, number]

    Returns LatLng

Static coordsToLatLngs

  • coordsToLatLngs(coords: any[], levelsDeep?: undefined | number, coordsToLatLng?: undefined | function): any[]
  • Creates a multidimensional array of LatLngs from a GeoJSON coordinates array. levelsDeep specifies the nesting level (0 is for an array of points, 1 for an array of arrays of points, etc., 0 by default). Can use a custom coordsToLatLng function.

    Parameters

    • coords: any[]
    • Optional levelsDeep: undefined | number
    • Optional coordsToLatLng: undefined | function

    Returns any[]

Static extend

  • extend(props: any): any
  • Parameters

    • props: any

    Returns any

Static geometryToLayer

  • geometryToLayer<P>(featureData: Feature<GeometryObject, P>, options?: GeoJSONOptions<P>): Layer
  • Creates a Layer from a given GeoJSON feature. Can use a custom pointToLayer and/or coordsToLatLng functions if provided as options.

    Type parameters

    • P

    Parameters

    • featureData: Feature<GeometryObject, P>
    • Optional options: GeoJSONOptions<P>

    Returns Layer

Static include

  • include(props: any): any
  • Parameters

    • props: any

    Returns any

Static latLngToCoords

  • latLngToCoords(latlng: LatLng): [number, number] | [number, number, number]
  • Reverse of coordsToLatLng

    Parameters

    • latlng: LatLng

    Returns [number, number] | [number, number, number]

Static latLngsToCoords

  • latLngsToCoords(latlngs: any[], levelsDeep?: undefined | number, closed?: undefined | true | false): any[]
  • Reverse of coordsToLatLngs closed determines whether the first point should be appended to the end of the array to close the feature, only used when levelsDeep is 0. False by default.

    Parameters

    • latlngs: any[]
    • Optional levelsDeep: undefined | number
    • Optional closed: undefined | true | false

    Returns any[]

Static mergeOptions

  • mergeOptions(props: any): any
  • Parameters

    • props: any

    Returns any

Object literals

Protected middleware

middleware: object

Object that stores the middleware functions and the default style

defaultStyle

defaultStyle: PathOptions = DEFAULT_STYLE

Generated using TypeDoc