Skip to content

Commit

Permalink
Remove features prior to major version 2.0 [#112, #121, #71, 55] (#129)
Browse files Browse the repository at this point in the history
* Remove features prior to major version 2.0, make parameter names consistent case. [#112, #121, #71, 55]

* Remove compat/json_style for MapLibre JSON styling
* Remove extra basemap styles
* Remove color shading feature of default style
* Remove user interaction, inspect and x-ray features

See CHANGELOG for explanations and alternatives.

* update CHANGELOG with 2.0 feature removal details [#122]
* Unify naming conventions [#112]
* change all internal and external-facing property and variable names to camelCase instead of snake_case.
  • Loading branch information
bdon committed Jan 27, 2024
1 parent a083044 commit 222b1c6
Show file tree
Hide file tree
Showing 30 changed files with 514 additions and 2,028 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# 2.0.0

Major version 2.0 aggressively reduces the scope of this rendering library.

This library re-focuses on being a Leaflet plugin for vector tile basemaps, i.e. "Mapnik in the browser"

* **All user interaction features are removed.** Every mapping application with clickable features should use MapLibre GL JS.

* **MapLibre JSON style compatibility is removed.** The surface area of the JSON style is too large to maintain for real-world use cases, and styles written for MapLibre perform poorly with this library.

* **Programmatic shading and extra basemap styles are removed.** This library's default style aligns with the 5 MapLibre styles developed in protomaps/basemaps.

# 1.24.2
* Continue internal refactors in preparation of 2.0.0 major revision.

Expand Down
15 changes: 15 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"formatter": {
"indentStyle": "space"
},
"linter": {
"rules": {
"style": {
"useNamingConvention": {}
},
"nursery": {
"noUnusedImports": {}
}
}
}
}
2 changes: 0 additions & 2 deletions examples/leaflet.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
if (!window.location.hash) map.setView(new L.LatLng(25.0412,121.5177),16)
var layer = protomapsL.leafletLayer({url:'https://api.protomaps.com/tiles/v2/{z}/{x}/{y}.pbf?key=1003762824b9687f'})
layer.addTo(map)
layer.addInspector(map)
// layer.removeInspector(map)
</script>
</body>
</html>
17 changes: 3 additions & 14 deletions examples/multi_language.html
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,6 @@
<option value="name:se">se</option>
</select>
</span>
<span class="control">
<label for="shade">Shade</label>
<input id="shade" type="color"></input>
</span>
<span class="comment">multilingual demo of <a href="https://github.com/protomaps/protomaps-leaflet">protomaps-leaflet</a></span>
</div>
</div>
Expand All @@ -191,27 +187,20 @@
})

var language1 = ["name"]
var language2, shade

document.getElementById("shade").addEventListener('change', e => {
shade = e.target.value
layer.setDefaultStyle(false,shade,language1,language2)
layer.clearLayout()
layer.rerenderTiles()
})
var language2

document.getElementById("language1").addEventListener('change', e=> {
language1 = e.target.value.split(',')
if (language1 === [""]) language1 = []
if (e.target.value !== "none") language1.push("name")
layer.setDefaultStyle(false,shade,language1,language2)
layer.setDefaultStyle(false,language1,language2)
layer.clearLayout()
layer.rerenderTiles()
})

document.getElementById("language2").addEventListener('change', e=> {
language2 = e.target.value.split(',')
layer.setDefaultStyle(false,shade,language1,language2)
layer.setDefaultStyle(false,language1,language2)
layer.clearLayout()
layer.rerenderTiles()
})
Expand Down
34 changes: 0 additions & 34 deletions examples/toner.html

This file was deleted.

49 changes: 0 additions & 49 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@
"@mapbox/unitbezier": "^0.0.0",
"@mapbox/vector-tile": "^1.3.1",
"@types/css-font-loading-module": "^0.0.7",
"color2k": "^1.2.4",
"flatqueue": "^1.2.1",
"pbf": "^3.2.1",
"pmtiles": "2.7.0",
"polylabel": "^1.1.0",
"potpack": "^1.0.2",
"rbush": "^3.0.1"
},
Expand Down
28 changes: 14 additions & 14 deletions src/attribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ export type AttrOption<T> = T | ((z: number, f?: Feature) => T);

export class StringAttr<T extends string = string> {
str: AttrOption<T>;
per_feature: boolean;
perFeature: boolean;

constructor(c: AttrOption<T> | undefined, defaultValue: T) {
this.str = c ?? defaultValue;
this.per_feature = typeof this.str === "function" && this.str.length === 2;
this.perFeature = typeof this.str === "function" && this.str.length === 2;
}

public get(z: number, f?: Feature): T {
Expand All @@ -21,11 +21,11 @@ export class StringAttr<T extends string = string> {

export class NumberAttr {
value: AttrOption<number>;
per_feature: boolean;
perFeature: boolean;

constructor(c: AttrOption<number> | undefined, defaultValue = 1) {
this.value = c ?? defaultValue;
this.per_feature =
this.perFeature =
typeof this.value === "function" && this.value.length === 2;
}

Expand All @@ -38,29 +38,29 @@ export class NumberAttr {
}

export interface TextAttrOptions {
label_props?: AttrOption<string[]>;
labelProps?: AttrOption<string[]>;
textTransform?: AttrOption<string>;
}

export class TextAttr {
label_props: AttrOption<string[]>;
labelProps: AttrOption<string[]>;
textTransform?: AttrOption<string>;

constructor(options?: TextAttrOptions) {
this.label_props = options?.label_props ?? ["name"];
this.labelProps = options?.labelProps ?? ["name"];
this.textTransform = options?.textTransform;
}

public get(z: number, f: Feature): string | undefined {
let retval: string | undefined;

let label_props: string[];
if (typeof this.label_props === "function") {
label_props = this.label_props(z, f);
let labelProps: string[];
if (typeof this.labelProps === "function") {
labelProps = this.labelProps(z, f);
} else {
label_props = this.label_props;
labelProps = this.labelProps;
}
for (const property of label_props) {
for (const property of labelProps) {
if (
Object.prototype.hasOwnProperty.call(f.props, property) &&
typeof f.props[property] === "string"
Expand Down Expand Up @@ -159,11 +159,11 @@ export class FontAttr {

export class ArrayAttr<T = number> {
value: AttrOption<T[]>;
per_feature: boolean;
perFeature: boolean;

constructor(c: AttrOption<T[]>, defaultValue: T[] = []) {
this.value = c ?? defaultValue;
this.per_feature =
this.perFeature =
typeof this.value === "function" && this.value.length === 2;
}

Expand Down
Loading

0 comments on commit 222b1c6

Please sign in to comment.