by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Brandon Liu
    @bdon_gitlab
    Hey all, is there a simple way to force labels on lines to be horizontal instead of following the path, to make very basic "shields" for linear (not point) geometries? (see road labels on screenshot) also, is this the main venue for chatting about Tangram right now?
    Brett Camper
    @bcamper
    @bdon_gitlab 👋 yep, easiest way is to take something like the shields layer in the Tangram demo, but remove the texture/sprites, and set the size of the point to 0: https://github.com/tangrams/tangram/blob/8554c270a60394f95c2181f4f33c264d81f1eef9/demos/scene.yaml#L436. The idea here is that when you apply a points-based style to line geometries, it will place them along the line, but leave them upright. It's usually with sprites, so setting the size to zero is kind of a hack, but should work. And yeah, this is a good Tangram chat venue, or feel free to file issues. Whatcha working on? ;)
    Brandon Liu
    @bdon_gitlab
    Screen Shot 2020-04-12 at 10.00.59 PM.png
    works now, thanks :)
    I've been thinking about 2 potential features. The first one is first-class support for variable fonts. That's what I'm using in the above map - a single .woff2 for fonts of all weights. it's a little hacky as-is since you need to declare multiple fonts in the YAML that point at the same file, but it's such a perfect match for web cartography that it seems worth supporting this directly. I also haven't tested this across legacy browsers.
    Brandon Liu
    @bdon_gitlab
    Second feature: the Tangram text rendering is much crisper for CJK compared to renderers that use SDFs. For these CJK use cases it would be great to have vertical text layout for point labels, extra nice to have vertical text for curved paths.
    If anyone has made progress on either of these two features or has any tips, I'm all ears
    andre9349
    @andre9349

    Hello, pls, help me. I'm trying to update my live data like you advised to @BossOfGames

    On top of my head you could wrap your SetDataSource in a ViewComplete callback hence only updating the datasource

        scene.subscribe({
           view_complete: function () {
                scene.setDataSource("traffic", { type: 'GeoJSON', url: 'https://localhost:44325/Home/GetVehicles?x={x}&y={y}&z={z}' });
            }
        });

    method executes as well but nothing happens.
    config param is the same as specified in scene.yaml
    How can i reload my datasource?

    Lucas Jung
    @lucas.jung_gitlab
    Hello. I am coding a multiplayer game, also I need to add username above Marker dynamically. But i don't found how to do that. Does anyone know how can I add text above markers ? With tangram-es
    Brett Camper
    @bcamper
    hey @bdon_gitlab, sorry for the delay... I agree those would both be great features, though I hadn't done much research into either (though I've had vertical CJK in the back of my head for a long time). I started looking into variable fonts today -- some promising results (for Tangram JS), but also an issue or two to work through. First of all, Tangram mostly passes through the font face values provided in the fonts definitions and draw parameters, so I was hoping this would "just work" (as always, it's a little more complicated than that). For reference, this is where Tangram loads the font face after the scene is parsed: https://github.com/tangrams/tangram/blob/master/src/styles/text/font_manager.js#L72. It has two paths, new FontFace() where supported, falling back to a CSS @font-face injection. After the injection, we wait to render any text until the fonts load using the FontFaceObserver library (https://github.com/tangrams/tangram/blob/master/src/styles/text/font_manager.js#L59, https://github.com/bramstein/fontfaceobserver). This is especially necessary for drawing text with Canvas (which is how Tangram renders labels, to various texture atlases), since it's pretty finicky.

    @bdon_gitlab here's what I tried. Using Voto Serif (https://github.com/twardoch/varfonts-ofl/tree/master/VotoSerifGX-OFL), I defined a weight range in my Tangram font definition:

    fonts:
        'Voto Serif':
            url: https://raw.githubusercontent.com/twardoch/varfonts-ofl/master/VotoSerifGX-OFL/Fonts/VotoSerifGX-VarTTF/VotoSerifGX.ttf
            weight: '28 194'

    (Got those weights after playing with the font in https://play.typedetail.com/.) I was then able to (mostly) get text to render by specifying different weights in different draw groups. To make this example, I modified by local Tangram build to let weight take a JS function in the scene file (not supported in current release, but easy to add). This shows NYC buildings with the font weight mapped to the building height:

    tangram-@16.1667&40.7091&-74.0084_2020-04-25_14.06.19.png
    In the scene file, that's:
                        font:
                            family: Voto Serif
                            # JS functions for weights not supported yet but could be
                            weight: |
                                function() {
                                    return feature.height || 28;
                                }
    Brett Camper
    @bcamper
    HOWEVER (party pooper time)... the main problem I've run into is that FontFaceObserver does not seem to work with this syntax. It always throws an error indicating the font isn't loaded. I have not yet looked into the code to see if that could be addressed (it doesn't look very actively maintained, though the library is still in wide use from what I can tell). Because of this, there are intermittent issues with the first rendered tile, where the font is either unavailable (falling back to default font), or where Canvas seems to report the width incorrectly, leading to cutoff labels:
    tangram-@16.1667&40.7027&-74.0129_2020-04-25_14.08.09.png
    (note those artifacts aren't present on the first screenshot, which was a time I got lucky and the font loaded before the tiles rendered)
    Similarly, there the labels on the bottom rendered before the font loaded, and used the default, while the top ones rendered later with the correct font:
    tangram-@17.1667&40.7093&-74.0094_2020-04-25_14.28.48.png
    I tried some variations in how the fonts are loaded, including turning off use of FontFace to see if FontFaceObserver would work with the CSS injection, but I seem to get the same result either way.
    Brett Camper
    @bcamper
    This also only addresses use of Tangram-supported font params for weight and style, not others like stretch, custom variation axes, or use of font-variation-settings syntax (https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Fonts/Variable_Fonts_Guide). That could all be added though, if the loading issue is resolved. I will copy this info to a github issue later, but figured the channel might be interested.
    (Will have to research vertical CJK for an assessment later :)
    Brandon Liu
    @bdon_gitlab
    @bcamper does the FontFaceObserver issue happen even if I specify each weight in a different font definition like this: https://github.com/protomaps/styles/blob/master/tangram/elements_light.yml#L123
    Brett Camper
    @bcamper
    @bdon_gitlab yes, that does appear to work OK as-is! Though I'd still like to also support the more concise range syntax (weight: 100 400). One thing though, looks like you need to tweak your syntax (nested YAML objects...), you have each property as an array, but you want an array of url/weight objects, like:
        Inter:
            - weight: 100
              url: https://cdn.protomaps.com/fonts/woff2/Inter.var.woff2
            - weight: 200
              url: https://cdn.protomaps.com/fonts/woff2/Inter.var.woff2
            - weight: 300
              url: https://cdn.protomaps.com/fonts/woff2/Inter.var.woff2
            - weight: 400
              url: https://cdn.protomaps.com/fonts/woff2/Inter.var.woff2
    Brett Camper
    @bcamper
    @bdon_gitlab I believe I identified the issue with range syntax and FontFaceObserver btw, it will try to feed the whole value into a font shorthand property, which generates invalid font values. But just taking the first property (before calling FontFaceObserver) looks like it works, since as soon as any one weight is available for the font, all of them should be. I'll be updating this in Tangram JS for next release and then the range syntax should be available in scene files as well.
    Matt Blair
    @matteblair
    @lucas.jung_gitlab Hi, sorry for the late reply! With Markers in Tangram ES you can use a 'points' style with a 'text' parameter (https://tangrams.readthedocs.io/en/latest/Syntax-Reference/draw/#text) to add a text label.
    To set the content to something like a name, it's a little awkward but I think the easiest way might be to use a JS function for the 'text_source': text_source: function() { return 'username' }.
    Matt Blair
    @matteblair
    The styling syntax is made for handling large numbers of features in a categorical way, so it's admittedly not ideal for manually specifying a single feature.
    There may be an argument though for adding a text_content parameter that allows specifying a string of content without creating and evaluating a JS function. This isn't the first time that it would've been helpful.
    Brett Camper
    @bcamper
    Yes, part of this awkwardness is that the text_source parameter was one of the first to support dynamic styling with feature properties, and while other parameters tend to take a string value as a literal (with JS functions for dynamic cases indicated with function() {... }), in the case of text_source, it was originally designed so a string value would indicate the name of a feature property, and we've kept it that way to maintain backwards compatibility.
    Brandon Liu
    @bdon_gitlab
    @bcamper thanks for catching that, fixed now :) duplicating the font multiple times like I'm doing still makes an XHR request for each entry, even if the woff2 url is the same. should this be easy to patch around by remembering which URLs have been requested already? if so I can work on that patch
    Brett Camper
    @bcamper
    @bdon_gitlab thanks, but I don't think so -- because the URL is passed to new FontFace() along with the other font face options, so I don't believe all the weights would get registered by the browser unless it is called each time. Did you definitely have your browser cache on? I'd hope/expect it would be smart enough to handle that since it's a native method, but sounds like maybe not. It would be possible if you used a composite cache key of the URL and all the other font params, but since I have a working fix for using range syntax with a single entry, I'd prefer to just wait for that (should be able to release soon).
    Lucas Jung
    @lucas.jung_gitlab
    @matteblair Okay I will test that thank you. Do you know if it's possible to add the text attribute to a marker style point ? Because I want to add the username above a user icon. Or I have to use two differents marker, a point and a text ?
    Lucas Jung
    @lucas.jung_gitlab

    @matteblair I tried what you told me but i always had the same Tangram error :

    E/Tangram: Error in font.xml parsing: END_TAG expected (position:START_TAG (empty) <axis tag='wdth' stylevalue='100.0'>@250:51 in java.io.InputStreamReader@793e0d9)

    I am using the marker's setStylingFromString() method with the following string :

    String pointStyle = "{ 'style': 'point', 'text': {'text_source': \"function() { return 'Test'; }\", 'font':{'size':'32px'}} }";

    I checked my string and i tried differents thing but I always had the same error.

    Matt Blair
    @matteblair
    That error isn't related to the point styling, it's something to do with loading one of the font files on the device.
    Lucas Jung
    @lucas.jung_gitlab
    Do you know how i can resolve it ?
    Matt Blair
    @matteblair
    I don't think the font parsing error should be impacting what you're trying to do - it's not uncommon and it should be harmless. Is the marker label not appearing the way you expect?
    Lucas Jung
    @lucas.jung_gitlab
    it is not displayed at all
    I don't sée my marker
    vilinet
    @vilinet

    Have you ever experienced issue after calling SetStylingFromString on a marker, the map stops refreshing. SetGeoJson, ClearData seemingly does nothing. But at panning the map gets updated and redraws/removes the features.

    If i call SetStylingFromString("{ style: 'points', size: '64px', collide: false, order: 3006}"), then the map renderingstill works but does not draw the marker.
    BUT as i add the color: 'white' to the style, the issue occurs.

    Cheers :)

    Lucas Jung
    @lucas.jung_gitlab
    I've tried a lot of thing to display my text marker but nothing works. Do you have an exemple of string to use in a SetStylingFromString to display a text ?
    Every time I used a function in text_source, like that 'text_source': \"function() { return 'Test'; }\" the app crash
    Lucas Jung
    @lucas.jung_gitlab
    when I use function in text_source, I have an error
    A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x88 in tid 31565 (GLThread 25498)
    vilinet
    @vilinet
    @lucas.jung_gitlab Waht about if you dont use quotes? 'text_source': function() { return 'Test'; }
    @lucas.jung_gitlab I think quotes meanit is a string, a function should not be quoted as it is a function.
    Lucas Jung
    @lucas.jung_gitlab
    It don't works. Or if works but the marker stills not displaying
    vilinet
    @vilinet
    Is there any methods that should be called in tangram-es to release it(dispose) from memory?
    vilinet
    @vilinet
    Hey guys i found some bugs in the style managment regarding visible property. Using a function: visible : function { return feature.is_visible; }
    First: Even when the is_visible is true, false in json, the false identified as a number 0(not as a bool), so it wont set the visible property in StyleContext::evalStyle
    Second: The DrawRuleMergeSet::evaluateRuleForContext
    It checks for visibility at the top, then it calls the evalStyle so it updates the visibility to false!
    But the visibility is not checked afterwards so it always rendered even when visibility should be false
    bnpIng
    @bnping
    Hi,
    Is their the trangram the notion pitch and bearing options in scene.yaml ?
    vilinet
    @vilinet
    Nope, you can only set it through the camera. At least i cant see any properties regarding this settings in the yaml.
    Matt Blair
    @matteblair
    @lucas.jung_gitlab Hey, sorry about the trouble you've had with Marker text. I was finally able to look into this in detail and found a bug that may have been impacting your use case (tangrams/tangram-es#2162). I tested out the Marker styling more thoroughly too and realized that text Markers will often be hidden in the rendered scene unless you add collide: false to the styling. Collision culling is enabled by default for text, including for Markers. Alternatively, you could make the Marker text hide other text around it with priority: 1 (or another sufficiently low value).