0.1.1 • Published 11 months ago

@okame/gmap-mvt v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

gmap-mvt

Library for displaying MVT source on googlemap

NPM version Downloads Github Open Issiues Github Closed Issiues GitHub forks GitHub Stars

This library is beta version!

This software has not been fully tested. If you find bugs, please create an issue.

Installation

# npm
npm install @okame/gmap-mvt

# yarn
yarn add @okame/gmap-mvt

Usage

# create google map object
const map = new google.maps.Map(element, {
      center: { lat: 35.692823106341834, lng: 139.71100348420828 },
      zoom: 9
})

# MVT source
const url = 'https://example.com/rain_layer'

# Options
const options = {}

# Create layer instance
const mapType = new MvtMapType(map, url, options)

# Add layer to GoogleMap
map.overlayMapTypes.insertAt(0, mapType)

Options for MvtMapType

nametypedescription
mapgoogle.maps.MapGoogleMap
urlstringMVT source url
optionsobject
tileSizegoogle.maps.Size
altstring
namestring
maxZoomnumber
minZoomnumber
projectiongoogle.maps.Projection
radiusnumber
stylegoogle.maps.Data.StylingFunction | google.maps.Data.StyleOptionsレイヤー内のFeatureに対するStyle定義
filterFeature(feature: GeoJsonFeature) => booleanレイヤー内のFeatureの表示Filter

Styling

By setting a callback function as shown below, you can dynamically style observed values to options.style.

const style = (feature: google.maps.Data.Feature) => {
  const val = feature.getProperty('val') as number
  const fillColor = val > 50 ? 'red' : 'blue'

  return {
    fillColor,
    fillOpacity: 0.6,
    strokeWeight: 0
  }
}

const options = { style }
const mapType = new MvtMapType(map, url, options)

Filtering

By setting a callback function as shown below, you can filter features to options.filterFeature.

const filterFeature = (feature: GeoJsonFeature) => {
  return feature.properties?.val > 0
}
const options = { filterFeature }
const mapType = new MvtMapType(map, url, options)
0.1.1

11 months ago

0.1.0

11 months ago