I'm trying to add a lot of data to a google map (local 3MB+ kml file, will probably be more). I have tried using the KML-layer, but showing all these data seems to use a lot of processing power, so the application/map is getting laggy when scrolling around.
I tried splitting the KML file up into smaller files and loading them according to the camera's position, but I'm still having these performance issues. I also want to show most of the data when the users zoom level is low, so this is not an optimal solution anyway.
I have looked a bit into google fusion layers. Google fusion layers seems to have better performance but is only included in the javascript API for google maps.
Will GEO-JSon improve the performance significantly?
Do you have any tips in how I can encounter this problem? Thanks in advance.
I feel i have to answer my own question here. I tried using Geo-Json instead of KML and it increased the performance significantly. Together with Marker clustering from the google utility library i now have a pretty good solution.
I experienced some problems with placing a lot of polylines to the map, and it caused the app to skip alot of frames, but by adding them one by one with 10ms delay it worked pretty good.
Related
I'm currently using android-map-extensions to cluster markers on google map. However, sometimes two markers are clustered when they are really far, sometimes they have to be almost overlapping each other to be clustered together. I've been trying to wrap my head around this for a couple of days and haven't figured it out. Below is the examples (btw, sorry for the bad english and I don't have enough reputation to post images so imgur to the rescue):
should already clustered : http://imgur.com/MxyN9VI
should not clustered until zoom out far enough (1-2 more zoom level) : http://imgur.com/hVzMQfD
How can I fix this, changing the clusterSize as document does not really help
Android Maps Extensions uses grid based clustering and what you describe is part of how it works.
You have a couple of options:
writing your own clustering strategy for it (e.g. distance based)
finding a proper clusterSize for your case; this might work if all your markers have fixed and static positions; keep in mind choosing between 128 and 128.1 can make a big difference
trying out a different library, e.g. Clusterkraf or Android Maps Utils, which use distance based clusering
Disclosure: I'm a developer of Android Maps Extensions
I am trying to compare native google maps (v2) vs the embeddable HTML version encapsulated in a webview on android. While it's pretty evident that the native maps are smoother and faster, I must prove that somehow. I have been searching on the internet for quite some time and did not seem to find any existing benchmarks. Does anybody know someone who actually done something similar? I am already thinking of creating such benchmark of my own, but how can the performance actually be measured? My ideas so far are:
Measure rendering of different number of markers, polylines, etc...
Measure map tile loading (maybe not possible at all)
Somehow measure the lag when dragging the map. This must be somehow based on the map events, but the native GoogleMap class does not seem to have something like onDragListener.
If you have any ideas or know some existing resource, please help me!
-----------------EDITED 03.01.2014----------------
I already started creating my benchmark but now I am struggling with some strange issues - see this question for more details.
The source code of the first version of my benchmark can be found here. It currently does not include automated testing. Nevertheless when experimenting with adding different number of markers and lines you can get an idea of how slower html maps are. I have also uploaded a simple demo on youtube, to view it click here
So Your topic is pretty interesting, but remember if you are going for google maps on mobile vs web, there is mobile v2 and javascript v3. Javascript google maps has some added functionalities that mobile does not offer, you can refer the docs to find out. AND You can perform on various parameters like.
1. Time it takes to load (display) the map on the screen.
2. As you mentioned rendering on the map.
3. Performance issues on low bandwidth.
4. UI and UX.
5. Reliability
6. User Satisfaction
7. Implementation (Complete off topic but since you are doing a thesis I will recommend that)
8. Features
9. At last pricing. (I think upto 20000 calls per day is free on one API key on javascript v3)
NOTE
Anyone feel free to edit and add some more parameters for benchmarking.
After plenty of searching, I haven't yet found a solution that works for me and I'm really hoping someone here could help me. First I'll explain my problem, and then I'll mention some of the approaches I've attempted/considered so far.
Basically, I'm developing an Android app where markers randomly appear around the user's location. The catch is, the markers need to be placed on streets only.
I've been working with Google Maps Android API V2 but I'm trying to work around using anything with "limitations" such as 'geocoding'.
I've considered using different map API's such as Nutiteq but I've had some trouble implementing them. It would be nice to stick to Google since I've become familiar with it but I'm willing to try any suggestions you may have.
I have even considered loading up Google Maps API V3 in an html file so that I can use GDirections to load a path from one point to itself and then parse this data to Google Maps Android API V2 using JS but turns out GDirections has a limit as well.
Anyone have any idea how I can go about doing this? Even if the solution is hacky, it's still something.
I'm fairly new to Android Development.
Funny what you want to achieve. You don't need to load API V3 html. You can use directions api directly: http://maps.googleapis.com/maps/api/directions/json?origin=51,19&destination=51,19&sensor=false
It still has limitations, but is was like 2000 or something a day a device. And you don't want to put more than 2000 markers on single user's screen, do you?
This is easy to parse, for example with Gson.
I am currently working on a school project and I am trying to learn the techniques on downloading OSM map tiles into the phone's local memory/cache, so that users are able to view the maps when offline.
This is to be done by giving a specific location, and the map tiles that are within specific radius/distance from the location will be downloaded into the phone memory (when there is online connection) for offline display.
However, I am having some slight trouble in understanding OSMDroid's APIs. From my understanding, it seems that the classes involved are:
MapTileBase
MapDownloader
IFilesystemCache
Please do correct me if I'm mistaken.
Also, in MapTileBase (which I believe is the provider), the getMapTile returns android.graphics.drawable.Drawable.
Is this Drawable class even related to the concept of offline map display?
Hope someone can enlighten me on where exactly maps are being called to be downloaded into the phone's memory, and how we can edit the maps to display interface items such as routes, pins, etc.
I don't have an exactly answer as you're looking for a method to cache offline outside of an area the MapView hasn't already navigated to. The built in caching support is there, but not exactly how you want to do it.
You're going to need online download capabilities if you plan to cache and not just supply your own offline map tiles. I would take a look at the MapTileDownloader and maybe try to implement your own version of it. The MapTileDownloader.TileLoader.loadTile() method takes a MapTileRequestState which I believe the MapTileProviderArray calls when a map tile is needed.
If you can replicate the existing MapTileDownloader's TileLoader functionality, you can probably inject your own relative MapTileRequestState or straight up MapTile's to the one requested. e.g. Take the TileLoader called MapTileRequestState, inspect it, figure out how to construct new MapTileRequestState/MapTile representing tiles outside the current view. It won't be easy though as you'll have to deal with the different zoom levels, and depending on the zoom level, the radius should be smaller, etc... A lower zoom level of 18 would have a larger tile radius than a higher 10.
Personally I was recently working on trying to work 100% offline so I don't have any example code to help. Good luck even though its been a couple of months.
First, go right the source
https://github.com/osmdroid/osmdroid
There's a few wiki articles that will help, especially the offline map tiles article. In short, use MOBAC or the tool osmdroid provides. OSMBonuspack also has a tool to perform the same task on device.
Map tiles are actually downloaded using this class
https://github.com/osmdroid/osmdroid/blob/master/osmdroid-android/src/main/java/org/osmdroid/tileprovider/modules/MapTileDownloader.java
I need a Map API for Android that can provide me with indexed nodes and indices that make up the road network. The main idea is to determine if two GPS devices are on the same road. Thank you in advance
A Map API by itself will not have that information. Anyway, you can get it from OpenStreetMap freely. You can download it from here.
I don't understand from your question if you intend on displaying the results on a map. If so, and you want a nice and free map API, I would suggest Leaflet. It's not as mature as the likes of OpenLayers but, as you've tagged this post with "android", Leaflet just kicks ass in the mobile department.
OpenStreetMap is definitely a good source of data for this kind of project. Unlike google maps, it gives developers access to the underlying vector data of a map (fully open). This allows interesting new use cases which simply are not possible with google maps, and something involving geometric calculations like this would definitely fit into that category. You either need OpenStreetMap or some other source of "vector" map data, and beyond OpenStreetMap this can be expensive.
Unfortunately that's not the full answer to your question. You still have a lot of work to do to use the data in the way you intend. You need to calculate the proximity of two points (GPS readings from two devices?) to nearby roads, and figure out which road the point lies closest to. It's the kind of powerful geo calculation you might do using a GIS package such as QGIS or a functions of a geo-aware database system PostGIS.
But that's not the answer to your question, because you need to do these calculations on device. I'm not aware of an off-the-shelf library to do this on android. I think you would have to roll your own.
But another challenge is to get the vector data onto the device in a suitable format in the first place, and this is the first thing to solve. You'd want the vector data either as a large download for a whole country, or perhaps a smaller area, perhaps with an on-the-fly download feature within this app. Whole countries are not infeasible when working with maps in vector form (ever tried the awesome MayDroyd app?), but require some compact formatting. Happily some of these problems are starting to be solved in open source off-the-shelf libraries. You could try to build on top of MapsForge for example.
So then you're back to the challenge of writing on-device code to poke around in this data and do the calculations you want to do. I suppose it could be rather good if projects like MapsForge included generic PostGIS style geo-functions to make this easier. Something to ask the mapsforge developers about perhaps.