Openstreetmap Overlay Osmdroid example - android

I am looking at the SampleWithTilesOverlayAndCustomTileSource example in the osmdroid pack and I am wondering where the overlay is coming from/what format the overlay openfietskaart-rcn is - is it Openlayers/a WMS service and how can I make my own custom overlay working for this example? Would it work with GeoServer? I was not able to find tutorials on this example and hope someone can give me a hint on how to create my own layer, based on a .kml file for example. Thanks!
this.mCustomTileSource = new XYTileSource("FietsRegionaal", null, 3, 18, 256, ".png",
"http://overlay.openstreetmap.nl/openfietskaart-rcn/");
example here:
http://code.google.com/p/osmdroid/source/browse/trunk/OpenStreetMapViewer/src/org/osmdroid/samples/SampleWithTilesOverlayAndCustomTileSource.java?r=829

The custom tile source doesn't specify a custom URL scheme, so you can assume it uses the default implementation - a folder structure of PNG files starting at the base URL above, followed by zoom/X/Y.png. The numbering matches Google Maps system. Each PNG is 256 pixels square. You can create a custom set of tiles using Mobile Atlas Creator (MOBAC), or I used a library called "mapnik" to convert KMLs to tiles. The tiles could also come from your sdcard.
Here's a good site to show how the tiles are numbered:
http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/
MOBAC:
http://mobac.sourceforge.net/
Mapnik:
http://mapnik.org/

Related

Flutter Google maps Markers incorrect size on iOS

The size of the markers on the map look different on iOS than android. I have tried several things, and the only thing that worked for me was changing the bitmap file of the google map plugin.
return BitmapDescriptor._(<dynamic>[
'fromAssetImage',
assetBundleImageKey.name,
4.0, // <= Replace 'assetBundleImageKey.scale' by '4.0'
]);
Is there a way to control the size of the asset? I tried modifying the image configuration size but this had no effect on either platform.
Secondary question, my marker is a simple circle with text in it. Is there a way to draw the circle and text with code and create a bitmap from that?
EDIT: I solved this issue by recreating all of the assets with the desired resolution and a 2x and 3x file. I generally do this working with Xcode and swift, but I inherited this project and the original assets did not include 2x or 3x.

Draw a marker in Mapbox Android from a custom external image URL

I am trying to figure a way to draw a marker in Mapbox Android SDK but all example show how to use a custom image from the DRAWABLE folder.
I would like to place a custom SVG icon from a custom URL. If not SVG at least PNG for transparency purposes.
Is it possible?
Examples that I found are similar to this one:
Bitmap icon = BitmapFactory.decodeResource(
MainActivity.this.getResources(), R.drawable.custom_marker);
mapboxMap.addImage(MARKER_IMAGE, icon);
With the caveat that in v7.0.0 you have the option to use the Annotation Plugin, which provides a slightly more intuitive, object-oriented way to set up your icon/annotation layer, here's my recommended approach:
The code snippet you've posted is one part of the Style -> Source -> Layer flow used for runtime styling in Mapbox's SDK. For your purposes, especially if you're adding multiple markers to your map with the same icon, you should add your markers via a SymbolLayer. There's a working example of how the SymbolLayer syntax works here (it also includes some code for adding interactivity to your markers). You can also get some quick boilerplate code over at Mapbox's marker playground.
To answer your primary question: the SDK doesn't include any convenience methods for loading an external SVG or PNG directly as a SymbolLayer's iconImage, so you'll need to use a library like Glide or Picasso to retrieve the image and convert it to a bitmap before passing it to mapboxMap.addImage().

How do I render an SVG in an Android app?

After finding Display SVG Image in image view in android on Google and going to Having issue on Real Device using vector image in android. SVG-android, I find that "You need a 3rd-party JAR to do it" is a bit of overkill. Is there any way to render an SVG without using 3rd-party libraries?
I managed to display an SVG using a WebView, since that is more than capable of rendering an SVG:
webView.loadUrl("file:///android_res/drawable/file.svg"); // point it to the SVG
webView.setBackgroundColor(0x00000000); // set the background to transparent
This makes it render much like a transparent PNG would in an ImageView. The only caveat is that the SVG must use the viewBox attribute and not use the height or width attributes, to ensure it resizes properly.
Using custom fonts actually works really well in Android.
You can use the free icomoon web application to convert SVGs to custom .ttf font characters.
If you are using it for imagePicker sort of feature then,
webView.loadURl(selectedFileLocation.toString)
else if it is to display a .svg image from web,
webView.loadURl(/*url for the .svg file*/)

Streetnames openstreetmaps more readable on Android

I've build an Android APP with offline map data using Openstreetmaps and OsmDroid. On a device with MDPI 320x480 pixels the map looks OK, but on a device with a HDPI screen with 480x800 pixels the street names are small and a little bit harder to read them. My map data till zoom level 18, the maximum I could download and use with Mapnik tile source, is loaded as a zip-file from the SD-Card. My local maps are from a defined region of Brussels (Belgium).
A screenshot of an MDPI device with 320x480 pixels:
A screenshot of an HDPI device with 480x800 pixels:
If you see these views in the app on the device the MDPI map is good readable, in the HDPI map the street names are smaller.
Is there a way to make the street names also more readable on the HDPI device, so the user haves the idea that he zooms one step further on the map? Because it's not possible to go to zoom-level 19, because there is no openstreetmaps data for it. So a little workaround solution with easy and small implementation time/work my be OK for me. Zooming is now done by swiping on the map. If you also need the code, let me know and I'll post it.
Thanks in advance.
Kr
Osmdroid works with tiles that are static PNG images. You can not change the tile images. If you want to have a better mapping solution try MapsForge. This app/library works with maps data and renders them dynamically. This way you have more control on rendering maps and you can customize its texts and fonts and colors.
In this answer I will explain a little bit how I changed the size of the street names.
In the jar file of MapsForge there is a xml-file included that will standard be used for rendering the map data. You can download this file also by checking out the source code from the server: http://mapsforge.googlecode.com or download the xml-file itself from here: http://mapsforge.googlecode.com/svn/trunk/mapsforge-render-theme/src/main/resources/osmarender/osmarender.xml. So, you have a basic to tweak your own render file. I tweeked it a little bit like this:
(snippet of the xml-file):
On the Wiki-page of the MapsForgeRenderThemeAPI page (on the site above) you can find how to tweak your own render file and what e, k, v attributes in the rule element means. As you can see there is a rule element with e="way", k="area", v="~|no|false" inside the no-tunnel way rule-element somewhere under the way rule-element. Every rule-element under this element haves
an e="way", k="highway" and v value equal to the openstreetmap parameters. As you login to the edit page on openstreetmap.org you can find out the kind of streets you want to tweak the names for.
Now I gonna tell how you can exactle the font-size you want for a specified type of street. As an example I will take the tertiary road element. Each kind of way rule-element contains some code like this:
<rule e="way" k="highway" v="tertiary">
<line stroke="#ffff90" stroke-width="1.5" />
<rule e="way" k="*" v="*" zoom-min="14">
<pathText k="name" font-style="bold" font-size="32" stroke="#ffff90" stroke-width="2.0" />
</rule>
</rule>
The line element specifies how the street will be displayed (color, width, black border, ...).
There is again a rule-element inside here containing a pathText element. This element specifies how the text will be displayed inside the stroke(color, width, font-size, ...). So, this is the element we need! In my example, as you can see, the font-size for the street names for a tertiary road will be displayed with a size of 32 pixels for a zoom-in-level of 14 or higher.
Now we want to use our own render theme xml file:
I've added my own render-xml file in the assets folder of my project. Than a t launch time, I copy the file to a location from where I can read it out when it is needed. In the activity where you handle your mapsforge map you only have to link to this file by implementing code like this (example):
File f = new File(Environment.getExternalStorageDirectory(), myRenderTheme.xml);
mapView.setRenderTheme(f);
Note that setRenderTheme(File) will throw a FileNotFoundException.
So, this is all for changing the street names with mapsforge. You can render you're whole map as you want!
Thanks to the MapsForge development community.
Have fun!
Kr

Making OsmDroid city label text larger

I find the text/labels for cities and towns to be rather small. Is there anyway i can manipulate the text size?
Osmdroid works with tiles that are static PNG images. You can not change the tile images. If you want to have a better mapping solution try MapsForge. This app/library works with maps data and renders them dynamically. This way you have more control on rendering maps and you can customize its texts and fonts and colors.
Take a look at this:
Streetnames openstreetmaps more readable on Android

Categories

Resources