Skip to content

Commit

Permalink
wip: Support new map styling #816
Browse files Browse the repository at this point in the history
  • Loading branch information
cnouguier committed Feb 10, 2024
1 parent dfb51fe commit 9d671f5
Showing 1 changed file with 9 additions and 40 deletions.
49 changes: 9 additions & 40 deletions map/client/leaflet/utils/utils.style.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,46 +187,7 @@ const PolygonStyleToLeafletPath = {
rule: 'fillRule',
}

//export const LeafletStyleOptions = _.values(LeafletStyleMappings)

export function createLeafletIconFromStyle (iconStyle) {
const iconOptions = iconStyle.options || iconStyle
let type = 'icon'
if (iconStyle.html) {
type = 'divIcon'
// Remove default background style
if (!iconOptions.className) _.set(iconOptions, 'className', '')
}
return _.get(L, type)(iconOptions)
}

export function createLeafletMarkerFromStyle (latlng, markerStyle) {
let options
if (markerStyle) {
// Retrienve the options
options = markerStyle.options || markerStyle
// Retrieve the type
const type = markerStyle.type || 'shapeMarker'
if (type !== 'shapeMarker') {
// parse icon options to create Leaflet icon
if (markerStyle.icon) {
const icon = createLeafletIconFromStyle(markerStyle.icon)
options = Object.assign(_.omit(options, ['icon']), { icon })
}
return _.get(L, type || 'marker')(latlng, options)
}
}
return L.shapeMarker(latlng, options)
}

export function createMarkerFromPointStyle (latlng, style) {
if (!latlng) {
logger.warn(`[KDK] 'latlng' should be defined`)
return
}
return L.shapeMarker(latlng, style)
}

// TODO: to be removed when updating 3D style
export function convertToLeafletFromSimpleStyleSpec (style, inPlace) {
if (!style) return {}
const leafletStyle = (inPlace ? style : {})
Expand Down Expand Up @@ -267,6 +228,14 @@ export function convertToLeafletFromSimpleStyleSpec (style, inPlace) {
return leafletStyle
}

export function createMarkerFromPointStyle (latlng, style) {
if (!latlng) {
logger.warn(`[KDK] 'latlng' should be defined`)
return
}
return L.shapeMarker(latlng, style)
}

function convertStyle (style, mapping) {
let convertedStyle = {}
_.forOwn(style, (value, key) => {
Expand Down

0 comments on commit 9d671f5

Please sign in to comment.