Showing a lot of points on Google Maps Android v2.0 - android

I have a lot of points to show on Google Maps Android. I decided to draw them on the map by drawing circles with small radiuses. However, I noticed that drawing a lot of circles (around 1000) is very slow and the app does not respond well, even when the drawing is made in an AsyncTask.
Any ideas how to get around this?

The best way is to only plot what you can see on the map and when the map moves get the new points you can see so that you eventually dont have to plot anymore.
You can also look into clustering where if you have a bunch of markers in a certain area you can indicate a group of markers by just plotting one marker
this link goes over the different method you can use
https://developers.google.com/maps/articles/toomanymarkers

Consider using Markers instead and one of the clustering libraries freely available:
Android Maps Extensions
Clusterkraf
Android Maps Utils
If you are convinced you want to use Circles, you may try to use one of the libs and modify code to group Circles.

Related

Lag when too many Marker Using ClusterItem Android Maps API

I use the util library maps android for Cluster item.
I have many marker but It's too slow on navigation.
Is there a way to optimize this apps?
You can see this video : https://youtu.be/lboDrBmI6xo
Here are suggestions to Optimize Maps with Many
Makers:
One approach at simplification is to render markers on the server. Google provides two services built into the API that make this easy to
achieve: FusionTablesLayer and KmlLayer. If you'd prefer to perform
computations on your own server, this can be accomplished by creating
a custom overlay from imagery that is pre-rendered, or rendered on the
fly.
Another useful optimization technique involves viewport marker management: restricting the markers rendered on the map into only
those that exist within the viewable area.
If you still want to display many markers on the map, consider creating a custom overlay that displays markers with minimal
functionality. This approach may garner performance improvements over
standard markers provided by the API.
Read more on the docs for optimization tips.
I believe that marker clustering is the way to go on Android and we have a utility library to use for this. You can check it out here

What libraries to use for Android Project with maps and routing?

Alongside with my friends I am about to develop an android application. The application will use maps a lot, finding routes, placing markers, drawing predefined routes, stuff like that.
There is this Google Maps APIv2. So I tried it, write some code and looks good. I am able to place markers and draw polylines, however my application will have some predefined routes. One route is set of LatLng points. So I just add these points to PolylineOptions and add it to map. Great, it works.
But these predefined routes will be created in web-based application also using Google Maps APIv2 or similar api/library. Some streets are not straight they are curved so you need to create a lot of LatLng points to get it look nice which is very important. I can do this but I want to put only two LatLng points - at the beginning of the street and at the end.
Here is the image:
On the left, route has only two LatLng points (red dots) and that is desired shape of line. On the right same route with 2 LatLng points gives me route coloured in light blue, and this is what actually happens if I just add polyline to GoogleMap object. In order to create same effect as in left image, I need to create many LatLng (red dots) points which is not appropriate for those who will create these routes. So this leads us to routing problem which can be solved by using Google Directions API. Which solves the problem of drawing routes with less markers. Basically what I understood, this API for directions actually creates a lot of these LatLng points that I draw using for-each loop as seen on right part of picture above. And I need to contact Google Web Service for this so I need to have Internet connection - and this is the problem.
Sometimes internet will not be available hence I need some alternative solution. I've heard of Open Street Maps, but I am not sure how to use it and does it needs internet connection for creating these routes.
Is there any free library that offers offline routing and showing maps offline? Basically all map interactions must be done without use of internet.
But it is understandable if internet connection is needed only for the first run of application as it is needed for Google Maps APIv2, well application crashes until I turn on internet, after which any next run I do not need internet..
A web based application will be made for creating these routes and routes will be created by users for whom we develop this application. And as users can be very annoying they will demand some user-friendly and easy interface for creating routes. Telling them that they need to create 100 to 500 points for each route, and if there is 60-70 routes they will gladly say NO to our application.
Any advice? If it is possible, I can write my own routing algorithm for Google Maps to work offline, I am very skilful at "Algorithms and Data Structures" - any guides/tutorials for this? But I guess this map is just set of tiles, and does not have necessary information for finding route.... So please correct If I am mistaken for anything.
You can use the Scout SDK (provides a free usage quota) as it offers full offline maps, routing & navigation.
Have a look into the open source projects GraphHopper, Mapsforge and OpenScience-VTM which can do routing and/or maps offline. And all use OpenStreetMap data. Other projects exists of course, have a look here and here.
Also have a look into the GraphHopper map matching component which could be interesting for your specific use case and can work offline too.
(Note I'm the author of GraphHopper)
If it is possible, I can write my own routing algorithm for Google Maps to work offline
No you can't, the data is not open nor you can buy the data to my knowledge.
Another option is OsmAnd. The OSM wiki also has some information about OsmAnd and even more information about OSM on Android in general as well as pages about rendering and routing.

android-map-extensions weird clustering behavior

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

Improving performance on google maps drawing long paths

This question is different than this another one
So, I have been observed the native google maps app when it draw long ways on the map.
When the zoom is too far, the lines are not full of details ... I mean, when we use the google maps api and request for a path between two different points we receive the whole coordinates for draw the most detailed path on the map.
As we change the zoom the drawn lines receive more details.
The question is. Is there a way to do something like the native google maps app ? Can we ask for less details to draw the path on the map using google maps api ? Can we improve the lines drawn details as we change the zoom ?
If the answer is "no" for all of my questions, here you go another one: How can we draw a long path on map without lag issues ?
I hope I've be clear, sorry about my English.
Google Maps is probably a bitmap of that path generated by the server. A new one for every zoom level.
You can do something similar but it's quite some work. But it should be faster to generate a transparent bitmap once instead of drawing the path each time the view needs to refresh. You can also draw a path with reduced details if you simply skip some points but finding an algorithm that does not skip the important parts is quite tricky.

How do i implement falling pins animation for markers in android map view

Is there any way to implement falling pins/markers animation for google maps in android like that in iPhone ???
Android has overlay markers (see ItemizedOverlay) that make it easy to add images to maps, BUT note that, in my experience at least, animated images do not work when added to overlays.
I found it necessary to add a View on top of the MapView, and add imagery to that, and I've successfully added animated drawable images to the map using that approach. For more details see here:
Can I use AnimationDrawable in an overlay on a MapView?
But to be honest, you should remember that it's Android, and copying every little feature from iOS is unnecessary. Google Maps on Android doesn't use a pin marker, it uses a static blue spot - I'd say it's best to replicate that and remember your users are Android users, not iOS users - they want consistency across Android apps.
You could have a look in this docmentation: https://developers.google.com/maps/documentation/javascript/overlays
Here is an example map.
Just add this in your code:
marker.setAnimation(google.maps.Animation.DROP);

Categories

Resources