Android mapbox v10 - dynamically change the source url - android

We have a usual source url of something like https://my-source/{x}/{y}/{z}. When the user selects filtering options, we'd like to add these params to the url as something like https://my-source/{x}/{y}/{z}?my-param=true and instantly update the map.
Is this possible to achieve in mapbox?

Turns out this is relatively simple! If a little difficult to find, the code below will update the tile url dynamically:
val source = style.getSourceAs<VectorSource>(CHARGE_POINT_SOURCE_ID)
source?.tiles(listOf(newSourceUrl))

Related

Android WMS: Problems generating "bbox" using the OSMDroid library

I have a problem when consulting a WMS using the OSMDroid library, the problem lies in an erroneous generation of the bbox. For example, this is a good url with a correct bbox:
https://www.ign.es/wms-inspire/pnoa-ma?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&FORMAT=image%2Fjpeg&TRANSPARENT=true&LAYERS=OI.OrthoimageCoverage&srsname=EPSG%3A25829&TILED=true&WIDTH=256&HEIGHT=256&SRS=EPSG%3A25829&BBOX=580836.6437384554%2C4745328.435582805%2C581278.1741512696%2C4745769.96599562
However, using the OSMDroid library, It shows me a white square for the badly generated bboxes:
https://www.ign.es/wms-inspire/pnoa-ma?SERVICE=WMS&request=GetMap&width=256&height=256&version=1.1.1&layers=OI.OrthoimageCoverage&bbox=580836.6437384554%2C4745328.435582805%2C581278.1741512696%2C4745769.96599562&srs=EPSG:3857&format=image/png&transparent=true
What I tried is this code that generate a WMSTileSource, which is set on the map:
val tileSource = WMSTileSource("OI.OrthoimageCoverage", arrayOf("https://www.ign.es/wms-inspire/pnoa-ma?SERVICE=WMS&"), "OI.OrthoimageCoverage","1.1.1", "EPSG:3857", null, 256)
binding.map.setTileSource(tileSource)
This error is due to the bbox, is there any configuration that should be done in the bbox or some way to handle it in a more customized way?
This should give me a map painted like this:
However, when I compile, it just shows me a blank map:

Which android view should be used to display a jetbrains.letsPlot() + geomHistogram() -object?

I am having some trouble including a Plot-object (produced by jetbrains.letsPlot() + geomHistogram()) within the activity.xml for a Kotlin Android app. I am familiar with basic activity elements but I don't know which one to use in this case and I can not figure it out using https://github.com/JetBrains/lets-plot.
Any help is very appreciated!
You can use Android' WebView to display a plot.
jetbrains.letsPlot() + geomHistogram() produces a Figure object.
First you will have to convert it to a simple Map object using toSpec() method:
val spec = when (plot) {
is Plot -> plot.toSpec()
else -> (plot as GGBunch).toSpec()
}
Next, you will generate a string (plot HTML representation) using PlotHtmlHelper:
val html = PlotHtmlHelper.getStaticDisplayHtmlForRawSpec(spec)
This way you can generate a web page and load it to WebView. The page should also contain a script tag for loading the Lets-Plot JS library.
The code could look similar to this (but with a newer library version - 2.2.1 currently): https://github.com/JetBrains/lets-plot-kotlin/blob/master/demo/browser/src/main/kotlin/frontendContextDemo/BrowserDemoFrontendContext.kt
If you are using Kotlin/JS you may want to take a look at this example as well: https://github.com/alshan/lets-plot-mini-apps/blob/main/js-ir-frontend-app/src/main/kotlin/Main.kt

Here-SDK: How to show the default HereWeGo-Positionindicator?

How do i show the standard PositionIndicator from the HereWeGo-App in my MapActivity?
This one:
When i use this Code:
mPositioningManager = PositioningManager.getInstance()
mPositioningManager.addListener(
newWeakReference<PositioningManager.OnPositionChangedListener>(MyActivity.this));
if (mPositioningManager.start(PositioningManager.LocationMethod.GPS_NETWORK_INDOOR))
{
mapFragment.getPositionIndicator().setVisible(true);
}
i get this Indicator:
Is there some other way to create the "HereWeGo-Indicator"? As i know if you implement the Indicator iOS you get by default the "HereWeGo-Indicator".
If you want to use image than do like below
Image img_current_location = new Image();
img_current_location.setImageResource(R.drawable.custom_img);
after that set on PositionIndicator.
Map.getPositionIndicator().setMarker(img_current_location);
And if you dont want to use image at all than create compass header. sample example can downloaded from the below link.
https://tcs.ext.here.com/sdk_examples/CustomPositionMarker.zip
some discussion can be found on this post.
It does not fit in your requirement but you can modify it.

How can I change the ordering of Crop Effect given by Aviary for Android

I am using Aviary version 3.1.1 to provide effects for photos in android. But I want user to directly jump to Crop screen in Aviary. I don't want to remove any of them but just chage their ordering. Please refer to the pic below:
Also inside the Crop page I want to remove all the other options except Square. Please refer to the image below:
I have looked in SO for this too but cannot find any related Docs in Aviary or SO. Please help me to resolve this doc with some links.
Thanks in Advance.
This issue was resolved later by me. I have used Aviary library "Aviary-Android-SDK-3.2.0" (However this has no relation to my answer and I have used this as it was the latest at that time)
1) For the first point, while calling FeatherActivity.class from your code, please do this:
String[] tools = new String[] { "CROP", "ENHANCE", "EFFECTS",
"BORDERS", "STICKERS", "TILT_SHIFT", "ADJUST",
"BRIGHTNESS", "CONTRAST", "SATURATION", "COLORTEMP",
"SHARPNESS", "COLOR_SPLASH", "DRAWING", "TEXT",
"RED_EYE", "WHITEN", "BLEMISH", "MEME", };
Intent newIntent = new Intent(this, FeatherActivity.class);
newIntent.setData(Uri.parse(data.getData().toString()));
newIntent.putExtra(Constants.EXTRA_TOOLS_LIST, tools);
// extra-api-key-secret
newIntent.putExtra(Constants.EXTRA_IN_API_KEY_SECRET,
Constant.AVIARY_API_KEY_SECRET);
startActivityForResult(newIntent, AVIARY);
Hence for that issue, we need to exceptionally pass all the variables we want and in that exact order, we will see that in our app, as suggested by cjwirth here.
2) Now for the second point, we need to edit aviary_config.xml of Aviary SDK. The aviary_config.xml file contains all the customizable behaviors of the SDK, like the colors to show inside the text tool or the drawing tool, the sizes of the brush tools, the custom crop ratios for the crop tool, the default font used in the meme tool, etc. You could also look for that here in official Aviary site.
Just change the past as:
<string-array name="aviary_crop_labels">
<item>#string/feather_square</item>
</string-array>
or any options you want from the given.

using WebView to view map and set marker (pin) on android

I'm making an app on android, using webview to load google map (using this url for my webview: http://gmaps-samples.googlecode.com/svn/trunk/articles-android-webmap/simple-android-map.html).
but i can't put a marker on that webview, can't somebody tell me how?
http://maps.google.com/maps?saddr=37.423156,-122.084917
The above simply shows the directions screen with missing destination field. If you want the pin to show on a simple map screen do this instead:
http://www.google.com/maps?q=37.423156,-122.084917
Clearly lots of ways to skin a cat - but I am loving the Google Static Maps API.
It generates a standard image (of desired size) and you can add points/lines/polygons all from a URL.
Whilst I haven't checked the terms, it is clearly possible to cache/store the result.
Documentation: http://code.google.com/apis/maps/documentation/staticmaps/
Example: http://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=14&size=512x512&maptype=roadmap&markers=color:blue%7Clabel:S%7C40.702147,-74.015794&markers=color:green%7Clabel:G%7C40.711614,-74.012318&markers=color:red%7Ccolor:red%7Clabel:C%7C40.718217,-73.998284&sensor=false
http://maps.google.com/maps?saddr=NJ
load URL like this pass address where you want to put the pin

Categories

Resources