Replies: 1 comment 2 replies
-
I expected something to work in a manner that it just doesn't. Honestly I'm not sure why I expected the TileJSON type of Maputnik to understand whatever json Martin is serving on the base MBTiles URL. I suppose I thought I was onto something when I was able to see data in Maputnik's Inspect view. So Here's what I've done that seems to be working great for me. Unsure if this is the best approach. but I figured I would at least share what worked. Martin has always worked fine, so nothing changes in the simple Martin startup above. Export "myStyle.json" from MaputnikI run Maputnik first to generate an almost "empty_style.json" file.
In the Maputnik browser window at: http://localhost:8000
Restart Maptunik with live editsYou may use the downloaded "myStyle.json" (or any other name given) in the place you stored it. In this example I copy "myStyle.json" into a "static" folder, because I use it later in that location. The file copy and restart of a local Maputnik with additional options looks like this:
Normally I use the Google-chrome web browser. But Firefox offers a very nice JSON view. And JSON is what Martin return when you navigate to it's base MBtiles URL. In my case that base url is: "http://localhost:3000/osm-2020-02-10-v3.11_north-america". Under the tag "vector_layers" you will fine the tags of "id" and "fields". Maputnik's "Add Layer" form has four fields: ID, Type, Source, Source Layer. Use any "ID" that makes sense to you. Select a "Type" of map viewable object to create (like Fill, Line, or Symbol). For the "Add Layer" form's last two fields are: "Source" and "Source Layer". "Source" must match a "Source ID" value previously entered in "Data Sources" (I used "openmaptiles" because many other styles used it). The "Source Layer" field must match an "id" value found under "vector_layers" in the JSON. The Maputnik form "Source Layer" value must exactly match one of the JSON "id" values. Inside the JSON file under "vector_layers" you will find multiple "id" tags with values like: water, transportation, places. That value goes into the "Source Layer" form. While working with this layer the associated JSON "fields" will be of interest, almost certainly the one called "class". Matching hintsOnce you have added Layer, make sure it's selected in Maputnik before you start editing. If you just added a new layer, you may find yourself editing the prior layer, I did it frequently. The View=Inspect is really useful to see what field values you wish to match on. However you will only see objects that match your currently selected layer's "Filter". Once you define a Filter you don't see any other options. To see what you have filtered away just invert the Filter by selecting "no filter matches". Remember to swap it back when you're done. Matching and using Maputnik function syntax is confusing. Even the small amount I know would take at least as much space as this to scratch the surface. My hints are: Maputnik "fx" functions are text arrays. MapLibre GL live view from FlaskYou may continue editing and viewing in Maputnik. I wished to confirm the style worked in my own web server, and also save working versions. I did this by created a Flask static server with a MapLibre GL website instance under static/. Here is my app.py:
Assuming the "static/index.html" referenced a "style:" path of: "/static/myStyle.json". Continue editing the style using the Maputnik web service (with the --file flag and json file reference). Maputnik will keep the "static/myStyle.json" file updated as you work on it. You may preserve "static/myStyle.json" by making additional file copies (or git commit) whenever you wish to. Any web instance using "static/myStyle.json" can be shift-reloaded to view the current Maputnik style. Hope this helps some other newbie trying to sort all this out. And leaves more time for the great work being done on this project. |
Beta Was this translation helpful? Give feedback.
-
Platform is Beelink 5700U miniPC running Ubuntu 23.10 fully updated.
Martin
Martin serves the mbtiles bundle perfectly on port 3000 with the command line reference:
martin ./osm-2020-02-10-v3.11_north-america.mbtiles
Maputnik
Running the Linux maputnik with:
Once the Source window is closed, change the "View" to "Inspect".
Inspection data is displayed and layers can be defined to show data when the View is set back to "Map" . For example adding a Layer for id="water" can be filled with blue.
Map tiles are each displayed correctly but NOT correctly located. I believe they are being selected by x,y,z and NOT the z,x,y format value given "tiles" in the martin supplied json. This value appears to be ignored, or perhaps a TyleJSON URL always defaults to x,y,z access?
From Maputnik you can "Export" and "Download" the generated style. Directly using the DL style in MapLibreGL also seems to tile oddly.
This can be fixed by editing the saved style and changing the appropriate "Sources" line from:
to:
MapLibreGL and Maputnik (with "--file DL.json") will then show the tiles located correctly in the newly defined style.
Which is great except that in Maputnik View="Inspect" no long knows about the "fields" it saw using the TileJSON style.
Ending up the same place you do by selecting "Data Sources":
Is there a way to alter what martin sends in the mbtile reference? Is Maputnik just not interpreting it correctly? Should I open a issue with them?
Beta Was this translation helpful? Give feedback.
All reactions