how to load text layer in mapbox-gl style / tileset - mapbox

I'd like to do exactly what https://api.mapbox.com/styles/v1/zugaldia/cimteac7b00mrb8m7okkkol8d.html?title=true&access_token=pk.eyJ1IjoienVnYWxkaWEiLCJhIjoiY2ltNnI0YXM0MDA0YXR5bHgxOTU0N2h5YyJ9.kBUkyDqT5S1gJOsMIAdJSw#11/38.8993/-77.0146 is doing.
It seems to use the MapBox GL tileset and style to place text on the map. It even shows more text at a zoomed in level.
How do we do that?
Can you point to a detailed example or video that shows the steps for loading the tileset (maybe from a GeoJSON file, etc)
Thanks.
It is really nice that we can do so much without javascript at all :)
This makes it easier for Android and iOS etc.
Notice the text for the School names:
Then when you zoom in, you see the text for the crime:

That is indeed a very nice map, he created it using Mapbox Studio uploading crime and school data as layer sources. You can learn more about creating your own map style by following along with the "design a map" guides. Once you've created a map you'll need to get the style ID by doing this:
(source: mapbox.com)
and then...
(source: mapbox.com)
Now you also mentioned using these maps within your Android or iOS app which is similar to using the api (link you gave above). Follow this example about including Mapbox studio style in your Android app. The example places the style url within XML like so:
<com.mapbox.mapboxsdk.maps.MapView
...
mapbox:style_url="mapbox://styles/<your-account-name>/<your-style-ID>"
/>
Hope this helps!

Related

GeoTiff style layers shows up with black borders in Android

We uploaded a set of "floor plans" to Mapbox in GeoTiff format. While layers show up fine in Mapbox Studio, the layers appear to have a huge black background surrounding it's rendered area.
This is how it looks in Studio
And this is how it appears in out app
We tried following the guide on documentation yet we don't understand it quite clearly:
This is the current code in charge of the map loading
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(new OnMapReadyCallback() {
#Override
public void onMapReady(#NonNull MapboxMap mapboxMap) {
mapboxMap.setStyle(new Style.Builder().fromUri("mapbox://styles/gustavjohannson/ckpzb9eop05mq18qviptlbm5d"), new Style.OnStyleLoaded() {
#Override
public void onStyleLoaded(#NonNull Style style) {
I just resolved this same exact issue. Check out this link.
https://docs.mapbox.com/help/troubleshooting/raster-transparency-issues/
It gives a useful example for android.
Basically you have to use a standard style like SATELLITE_STREETS or STREETS or whatever you choose. But do NOT embed your map overlay into the style. You want to add your overlay as a Raster Source tileset directly in your android code.
Here's what my code looks like:
mapboxMap.setStyle(Style.Builder().fromUri(Style.SATELLITE_STREETS)) {
loadedMapStyle.addSource(RasterSource("source-id",
TileSet( "tileset-id", "https://api.mapbox.com/v4/HERE I PUT MY TILESET ID/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoidG9tbXlib21iIiwiYSI6ImNqZXg5NHZlcjB6czEyd3J5MnAxZDdieGYifQ.GUqv9fHb__o5Xq8DLdNnnA"), 256))
loadedMapStyle.addLayer(RasterLayer("raster-layer", "source-id"))
}
Remember...In Mapbox Studio... Instead of creating a custom style with your map embedded, create a custom Tileset with your map and use that tileset id in your android code.

Unity WebGL Mobile browser workaround and keyboard input fix?

Hey everyone so I read that unity doesn't really support mobile browsers for WebGL games. im using 2020.1.4.And sure enough, the game gets a bit distorted by not being scaled properly. it's like the camera is bigger so it shows on the screen that blue color. I tried some things, setting width and height to auto or removing config.devicePixelRatio = 1; as suggested by a friend but nope! still looks horrible! And if that wasn't enough the keyboard doesn't show up when clicking on form fields. i tried this one
https://github.com/eforerog/keyboardMobileWebGLUnity
which displayed an error when pressed on and this one
https://github.com/dantasulisses/WebMobileInputFix which just didn't even compile!
Any ideas, please?
I did my research and tried every plugin I could find. I used Unity 2020.3.28f1 and tested both on Android-phone and iPhone.Here is my report.
These plugins don't work:
https://unitylist.com/p/f58/Unity-webgl-inputfield
https://github.com/eforerog/keyboardMobileWebGLUnity
https://github.com/dantasulisses/WebMobileInputFix
This plugin works, but you should use different settings for IOS and Android on same input field game object. If you use "prompt", it works for IOS only, and "overlay" works for Android only. Look for documentation in page:
https://github.com/unity3d-jp/WebGLNativeInputField
And this plugin works best at the moment. Yes, it is a bit ugly though, but it works.
https://github.com/kou-yeung/WebGLInput
And there is a fix for Unity 2021 for it:
https://github.com/kou-yeung/WebGLInput/releases/tag/1.0
There's a keyboard that overlays, when using it you just need to tap the notification to access it and then click the "back" button to hide it https://play.google.com/store/apps/details?id=com.fishstix.gameboard
I made this project that simply recreates a keyboard using buttons in unity.
I implemented it in a WebGL build successfully.
https://github.com/thetimeste/WebGL-Build-Keyboard-Unity.git
I would recommend using the native js window.prompt() fields as of writing. They have great cross-platform support, allow for extra features like special characters, emojis, copy and paste etc. and are pretty easy to set up. Once (or honestly if ever) Unity adds their own reliable implementation you can easily remove this lightweight implementation.
Create a .jslib file that has a function opening a window.prompt(description, currentText)
Return the result at the end of that function back to a unity object with a recipient script
Make a derivation from Unity's event system overwriting the OnApplicationFocus(bool focus) function (leaving it empty), to fix a sneaky Chrome Android bug.
That's it. The result should look something like in this demo: https://pop.demo.neoludic.games
If you want to save some development time on a feature that really should just be native in Unity, you can also check out my plugin based on the method above. https://neoludic-games.itch.io/pop-input
I also need to enable mobile virtual keyboard for running webgl on mobile device.
I've tried the code from your mentioned url. It gives you some idea on how to do
it, but the code are totally buggy and unusable. Now I am trying to implement it
by myself.

change openstreetmap TYP in an android app?

I use an OSM map in an android application using the osmdroid package and it works fine. The only thing I want to change is the visual appearance of the map to a typ, which is called "outdoor" style. I tried all the possibilities given in the setTileSource()-Function, but no map displays the map like in the piicture below. Is there a simple way to set a parameter somewhere to get the desired appearance of the map? I have seen some app's using this appearance. Thanks!
mv.setTileSource(TileSourceFactory.MAPNIK);
this is what I want to display

Use DroidText for barchart

I am just trying different pdf making library for some research in android. I have one question regarding this. How can we make bar charts , pi charts using droidtext as PdfGraphics2D is not available. Not from itext, I already know.
You can use a chart library like achartengine (https://code.google.com/p/achartengine/) or afreechart (https://code.google.com/p/afreechart/) to create the chart and save it as an image. Afterwards add the image file to the pdf.
There are currently no plans to add PdfGraphics2D support to droidText.

Using iOS 5 rich text editor

as you know the Mail app in iOS 5 have a rich text editor is there any possible way to use this feature for a regular UITextView ?
I know of two fundamental approaches to creating a rich text editor in iOS 5:
Use Core Text and a custom view. I don't have any experience with this approach.
Use a UIWebView (instead of a UITextView) and the contentEditable HTML attribute. The basic idea is to load a custom HTML document from your app resources directory. The bare minimum that it needs is this:
<div contentEditable>TEXT_PLACEHOLDER</div>
To initialize the rich text editor view:
1. Load the contents of this file into an NSMutableString and replace the TEXT_PLACEHOLDER string with the text you want to edit.
2. Send the loadHTMLString:baseURL: message to the UIWebView with that HTML string.
Now you have a UIWebView displaying your text inside a div with contentEditable. At this point, you should be able to run your app tap on the text, and be presented with a cursor and be able to add/remove text. The next step is to add rich text formatting functionality. This is done with a set of simple javascript function calls. See the Mozilla documentation on contentEditable for a great reference. You will also want to add a Javascript function to your HTML template file like this:
function getHtmlContent() { return document.getElementById('myDiv').innerHTML; }
So you can easily retrieve the edited text as HTML using [myWebView stringByEvaluatingJavaScriptFromString:#"getHtmlContent()"]. You can also add custom context menu items like you show in the screen shot in your question.
If you have access to the Apple iOS dev center, the WWDC session Rich Text Editing in Safari on iOS talks all about this approach.
A variation of this approach is to use a third-party rich text editor like TinyMCE. I've heard of some success with integrating this into a UIWebView in iOS 5. Again this relies on the contentEditable attribute.
Here is my implementation. Still haven't added UIMenuController functionality, but it's planned to be added soon.
https://github.com/aryaxt/iOS-Rich-Text-Editor
The iOS 5 rich text edit control is also present in the notes app in iOS 4 (make a rich text note on the computer and sync it to see).
This is a custom Apple-made control which they use in their own apps, but it is not published in any official developer API. It's probably in the SDK somewhere, but because it is undocumented, even if you find it and use it, Apple will reject your app.
Basically, if you want a rich text control you will have to make your own.
Edit: Try using this: https://github.com/omnigroup/OmniGroup/tree/master/Frameworks/OmniUI/iPad/Examples/TextEditor/. I haven't used it, so I don't know how well it will work. (Link from this question)
look at https://github.com/gfthr/FastTextView which is more good open source editor than Omni editor