B4A Library OSMDroid - MapView for B4A

peacemaker

Well-Known Member
Licensed User
No, exactly device screen X\Y would be OK. I'm already using TouchEventsOverlay, that is the problem - to combine overlay's coordinates and screen coordinates of the same tapped screen point.
 

peacemaker

Well-Known Member
Licensed User
OK, i'll try to get them via Mercator calculations, basing on MapView1.GetCenter and tapped GeoPoint.

UPDATE:
B4X:
Sub GetScreenCoords (TappedPoint As GeoPoint)    'X1, Y1 are global tapped screen point coordinates over the Map
Dim m As Mercator, p0 As GeoPoint, X0, Y0 As Int
p0 = MapView1.GetCenter
X0 = m.LonToX(p0.Longitude, MapView1.Zoom)
Y0 = m.LatToY(p0.Latitude, MapView1.Zoom)
X1 = m.LonToX(TappedPoint.Longitude, MapView1.Zoom)
Y1 = m.LatToY(TappedPoint.Latitude, MapView1.Zoom)
X1 = X1 - X0
X1 = MapView1.Width/2 + X1
Y1 = Y1 - Y0
Y1 = MapView1.Height/2 + Y1
End Sub
 
Last edited:

warwound

Expert
Licensed User
OK, i'll try to get them via Mercator calculations, basing on MapView1.GetCenter and tapped GeoPoint.

UPDATE:
B4X:
Sub GetScreenCoords (TappedPoint As GeoPoint)    'X1, Y1 are global tapped screen point coordinates over the Map
Dim m As Mercator, p0 As GeoPoint, X0, Y0 As Int
p0 = MapView1.GetCenter
X0 = m.LonToX(p0.Longitude, MapView1.Zoom)
Y0 = m.LatToY(p0.Latitude, MapView1.Zoom)
X1 = m.LonToX(TappedPoint.Longitude, MapView1.Zoom)
Y1 = m.LatToY(TappedPoint.Latitude, MapView1.Zoom)
X1 = X1 - X0
X1 = MapView1.Width/2 + X1
Y1 = Y1 - Y0
Y1 = MapView1.Height/2 + Y1
End Sub
Any luck?
Did it work?

Martin.
 

peacemaker

Well-Known Member
Licensed User
Sure, works :) Why to publish without questions.
Now it's possible to detect what is tapped - water, road or city.
 

warwound

Expert
Licensed User
OSMDroid 4.1 the next version...

I've had some time to work on the new version of OSMDroid.
This new version will wrap version 4.1 of the android java OSMDroid library - that's the latest version available.
The changelog for the android java OSMDroid library can be found here: http://code.google.com/p/osmdroid/wiki/Changelog.

The new version includes some new features and a lot of bug fixes and general code improvements.
  • Better memory management and handling of Bitmaps.
  • Improved pinch zoom - zooms on the point of pinch not the map center.
  • Map rotation now 'properly' implemented instead of the existing 'hack'.
  • Ability to limit the scrollable area of the map.
  • And much much more!

You can find a reference document that show's exactly how much of the new version i have wrapped so far here: http://b4a.martinpearman.co.uk/osmdroid/OSMDroid_4_1.html.
Much of the basic stuff wrapped and the 'marker overlays' being the main classes left to wrap.

The bad news is that the new version will not be a drop in replacement for the old version.
The current b4a OSMDroid_3_0_8 library has been updated many times since i first released it and to be honest the library source code is a bit of a mess - there's patches on patches and hacks on hacks lols.

The good news is that the new version will give access to more of the underlying android java OSMDroid library features.

So i'm wondering how many forum members out there are actively using the current version of the b4a OSMDroid library and how they feel about updating to a new version but having to modify their projects in order to do so.

If the new version requires you to make a lot of changes to your existing code would you simply not bother to update to the new version?

All and any comments welcomed.

Martin.
 

canalrun

Well-Known Member
Licensed User
I use OSMdroid quite a bit. I would upgrade to the new version very quickly even if it means making some changes.

I hope the new version would offer the same functionality – with some new features and improvements.

Although I've never tried the Google Maps library, I prefer OSMdroid. From what I have read OSMdroid provides a lower-level interface and the ability to customize things the way one wants them to appear. I also think I read that Google Maps only works with Android 3.0+. I like to support versions back to 2.3.

Barry.
 

JoeR

Member
Licensed User
I am a newbie to the world of apps - writing my first app - making considerable use of OSMdroid. If you are not happy with the technical insides of the current library, then I think that justifies the upgrade. But please - write a step-by-step checklist suitable for use by us newbies.

By the way - thank you very much for the significant effort which you have obviously expended on OSMdroid.
 

rboeck

Well-Known Member
Licensed User
Hi, i have invested much time to make an app, which uses Google Map. One month ago, i had a telephon call with google, because i wanted to know, in which situation we can use google maps for free, and when to we have to pay for the service. In short, as long we make free software, google maps is free, when you get some money, direct or indirect, you have to make an agreement and pay 14.000 € a year. It is calculated as 100 € per user and you have to license 140 users as a first step.
In my app google maps is nice to use, but not so essential. I currently use a map with markers over the maps api, and also use google maps over api. When i correctly understand, i can make as much as 2500 geocodings a day with the free version, so here me first question: is the google maps api key in use with geocoding and does it work without this key?
My next question: i have seen, that with osmdroid, one can download parts of the card for offline use. In many country parts of germany and austria the internet over mobile internet is not really reliable. So i think, my app would maybe be faster and more reliable, if i switch completly to osmdroid and use offline cards.
So my second question: what are the biggest differences between them and is it possible to have the cards of germany and austria on the mobile device; i know, it also a question at which zomming factor.
 

warwound

Expert
Licensed User
is the google maps api key in use with geocoding and does it work without this key?
You're referring to Google's HTTP Geocoding API there i guess and not the b4a Geocoder library?

Read the API key documentation on that page.
It states:
All Geocoding API applications should use an API key.
  • Enables per-key instead of per-IP-address quota limits.
Notice the use of the word should.

Further down the page is an example HTTP geocode request, i removed the (blank) API key part of the request and tried it in my browser.
It works without an API key.

https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false

So i think if you use an API key then your API key allows up to 2500 geocode requests in any 24 hour period.
And if you do not use an API key then geocode requests are limited based on the IP address of the device that made the request.
Does that mean that every IP address can make up to 2500 geocode requests in any 24 hour period?
I'm not at all sure.
You'd have to read through all the documentation and terms and conditions of use to try and find an answer.

But be sure to read the Usage Limits part of that webpage:
The Geocoding API may only be used in conjunction with a Google map; geocoding results without displaying them on a map is prohibited.
If you stop using a GoogleMap and switch to an OSMDroid map you're no longer allowed to use the Geocoding API service.

It might be worth taking the time to see if there's any other online geocoder services available.

So my second question: what are the biggest differences between them
GoogleMaps is (i think) a much more professional library.
GoogleMaps is supported by the massive Google infrastructure - tiles for your GoogleMap are served by massive server farms that serve tiles very quickly.
You're very unlikely to ever find a GoogleMap not responding because the tile server is overloaded.

OSMDroid is much less professional.
You have a choice of tile sources but these are mostly (or wholly) served by single tile servers where a single tile server must serve all tile requests.
Often these tile servers become overloaded and your OSMDroid map will hang waiting for tiles from the tile servers.


is it possible to have the cards of germany and austria on the mobile device
It's possible but not always practical.
First you need a source of tiles - if you want to add an offline tile archive to your app you first need the tiles with which you'll create your offline tile archive.
Take a look here: http://code.google.com/p/osmdroid/wiki/MobileAtlasCreator.
MobileAtlasCreator (MOBAC) is a tool that can download tiles from tile servers and package them into an archive ready to use with your app.
You choose a rectangular area of the earth, choose which zoom levels you want to include and MOBAC downloads and packages your tiles into an archive.
Choose a large area and/or choose lots of high zoom levels and you'll run into problems:
  • The tile servers that MOBAC is downloading the tiles from may temporarily block your IP address for requesting too many tiles in a short period of time.
    You can work around this as MOBAC has settings that let you limit how many tiles it requests at a time.
  • Your offline tile archive will soon become massive.
    It might become a few hundred MBs in size or even a GB or more.
    How will you make the offline tile archive available to your OSMDroid map?
    • A small tile archive can be included in the compiled APK.
    • A large tile archive would ideally be hosted on a server and once your app is installed it would download the tile archive to the device.
      This makes using a large tile archive possible but at some point you'd have to decide how large an archive it is practical to download.
      Few users of your app are likely to want to download hundreds or thousands of MBs of offline tiles.

An alternative to an offline tile archive is to render your own tiles on the android device.
Have you looked at the MapsForgeTileProvider for use with the GoogleMaps library?
I have a version of the MapsForgeTileProvider that works with OSMDroid.
So you could create a map database conatining binary data that covers the area you wish to display and use the OSMDroid MapsForge library to render tiles on the fly on the device from this maps database.
The library isn't perfect - read the post on the GoogleMapsExtras thread where i detail it's faults.
But if you'd like to try using MapsForge on an OSMDroid map you'll find the library files and an example project here: http://b4a.martinpearman.co.uk/osmdroid/MapsForgeTileSource.zip.

So offline mapping with OSMDroid is possible using either an offline tile archive or the MapsForge library.
Offline mapping is also possible with GoogleMaps using MapsForge library.

Whether you use offline tiles or MapsForge you will inevitably find that offline mappping requires a hundred or more MBs of tiles or data to be transferred to the device.

Martin.
 

Dario126

Member
Licensed User
Hi, i have invested much time to make an app, which uses Google Map. One month ago, i had a telephon call with google, because i wanted to know, in which situation we can use google maps for free, and when to we have to pay for the service. In short, as long we make free software, google maps is free, when you get some money, direct or indirect, you have to make an agreement and pay 14.000 € a year. It is calculated as 100 € per user and you have to license 140 users as a first step.
Well, then I don't understand this from https://developers.google.com/maps/faq?csw=1#usage_pricing ..
Where it says:


What usage limits apply to the Maps API?
Most websites and applications may use the Google Maps API free of charge. However, if you consistently generate a high amount of traffic, usage limits apply and you will need to pay for extra usage. If your site or application generates 25 000 map loads or more each day, for more than 90 consecutive days, we’ll get in touch with you to talk about payment. Don’t worry, if you go over the limits, we won’t immediately shut off your API access or display error messages on your site.

If you think your website or application will generate high map loads consistently in the long term, you should consider one of the following options:

  • Modify your application so that your usage is less than 25 000 map loads per day.
  • Enroll for automated billing of excess map loads in the Google APIs Console.
  • Purchase a Maps API for Business license.

...

Which Maps API services are affected by the usage limits?
The Maps API usage limits apply only to the following Maps API services:

The Google Earth API, and native Maps APIs for mobile platforms such as Android and iOS are not affected. Use of the embed feature ofGoogle Maps, and other Google products that offer an embed feature that includes a map, are not affected by these limits.


This sound that You have to pay only if you go out of 24hr limit, but for native Android map not even in that case. Right ?
 

rboeck

Well-Known Member
Licensed User
I would really hope, that the meaning of the text is so, like it sounds. I have transfered this text to my lokal google sales man and will post his answer, as soon as i get it.
 

Cesar Calagioni

New Member
Licensed User
Hello, is possible to mark a trace route two or more points. Show how to get from one point to another, and that I made the layout.

Thanks César
 

brelto85

Active Member
Licensed User
Is possible to check the speed limit with this library?
if it is possible how to do it?
thanks
 
Top