Android :: Problem Draw On A MapView ItemizedOverlay
Aug 27, 2010
I am developing an application for the Parisian Metro. One of the functions is a map where you can click the metro stations and see what are the metro lines, and when are the next 4 trains on this station.
I have hence created a MapActivity and an ItemizedOverlay classes.
On my device it is working perfectly, but I am getting some logs from the users with a crash, and I really don't understand what's wrong.
My map activity adds ONE ItemizedOverlay that displays a blue dot for the current user location. This overlay also listens to onTap, which depending on the coordinates of the tap, will try to find metro stations (for which I know the lat/lon coordinates). This is working perfectly.
The stack trace of the crash is:
CODE:.....................
Sometimes it comes from different lines but it always finishes crashing at OverlayBunde.java:42
As is does not mention my code, I don't know what's wrong.
You can get the source code of the MapActivity and the the ItemizedOverlay: http://code.google.com/p/metroparis/source/browse/trunk/src/org/bicou/metro/
The activity class is ACarteStations and the overlay class is StationMetroMapOverlay.
View 1 Replies
Sep 7, 2009
I've try to make a mapview with itemized overlay and it's not work. I share my code if anyone see anything :
java class mapview code...
View 4 Replies
View Related
Nov 23, 2009
In my application I would like to mark different spots on a map. What I'm now wondering is if there's a way to use a simple 9-patch image and add the spot's name as text to it or would I need to draw everything myself (including the text) in the draw() method of ItemizedOverlay?
View 1 Replies
View Related
Oct 20, 2009
I have been able to draw a map using 'MapActivity' class. Am unable to render 3D graphics on the Map. Is there any way to draw something on the foreground with the Map as the background?
View 2 Replies
View Related
Feb 14, 2010
i have a problem with my mapView. my app reads "some" gps points out of a file and i want to draw a route (drawing lines between the gps point). If my file contains many gps points, my app works really slow. i think its working slow, because i draw all overlays. now i want to check, whether a point is visible in my mapView or not. so i have to get the mapCenter and Lat/lon span (getLatitudeSpan,..) !? how and where must i save my points and how can i check all my points (after my mapCenter has changed for example). Shall I save my points in a list (in my Overlay class??) and iterate through every list item and check, wheter its visible or not?
View 4 Replies
View Related
Nov 12, 2009
I'm trying to draw some text onto an MapView on Android. The drawing of the text goes fine, but it's very hard to read the text because it's white with no black border (like the rest of the text that appears naturally on MapViews to denote cities, states, and countries). I can't seem to figure how to draw the text with a black border. This is the sort of code I'm using right now (this is just example code, found in one of my overlays):
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
Paint textPaint = new Paint();
textPaint.setARGB(255, 255, 255, 255);
textPaint.setTextAlign(Paint.Align.CENTER);
textPaint.setTextSize(16);
textPaint.setTypeface(Typeface.DEFAULT_BOLD);
canvas.drawText("Some Text", 100, 100, textPaint);
super.draw(canvas, mapView, shadow);}
View 3 Replies
View Related
Oct 1, 2010
Trying to solve my current problem of drawing an image on an Android MapView and then animate it to represent a moving object, I decided to try to just draw a raw ImageView at a GeoPoint on the map and then try and animate it from there.
This is the code I put in my map activity (extends MapActivity)'s onCreate method:
CODE:..............
Again, I'm just trying to draw the static icon and animate it from there. I can already do this with an ItemizedOverlay, but as far as I can tell, I can't animate the elements of an AnimatedOverlay the way that I can animate a view. Thus, using ImageView.
But the icon doesn't show up.
View 1 Replies
View Related
Aug 26, 2010
My Android application has a MapView. I want to divide that MapView into a grid according to latitude and longitude, and shade the different cells of that grid different colors based upon a certain criteria. What's the simplest way to do this?
I could create semi-transparent, solid-color PNG Drawable rectangular images and put them in an ItemizedOverlay centered on the central points of the cells, but then the rectangles would grow and shrink as the user zoomed in and out on the map. I could extend MapView and override the zoom functions so that the rectangles got re-sized when the user zoomed, but that seems really complicated for something that should be simple! Please tell me a better way to do it?
View 1 Replies
View Related
Aug 1, 2010
I wonder, how can I draw a nice flight route between 2 points on a google map's MapView? look at this: http://maps.forum.nu/gm_flight_path.html
View 6 Replies
View Related
Aug 2, 2010
I am writing a application that needs to draw a "route" comprised of lots of GPS points (long+lat). The points are close together and don't follow roads, simply drawing a line between each point is ideal.
The current implementation I have is very slow as I am looping over all the GPS coordinates and creating a new Point and overlayitem in an itemized overlay. This takes around 20 seconds for it to load all of these points and draw them to the mapview. Is there a way in which I can construct a series of lines or point from the GPS coordinates and draw them onto the mapview?
Example of current implementation:
CODE:...................
View 2 Replies
View Related
Jul 16, 2010
I had found a lot of stackoverflow post about save an Activity and the reload it.
My question: How can I have an Activity with an MapView and after reload the same mapview?
What is the best way to switch between activity and views?
View 2 Replies
View Related
Sep 5, 2010
In my android application I use this method in "draw" Overlay class for draw route on map. Can someone tell me if this method is good (in terms of performance) for route draw on map or I must to put code in Thread ??
I'm new to android.
public synchronized void draw(Canvas canvas, MapView mapView, boolean shadow) {
if (pointsAndTimes.isEmpty()) {
return;
}
Projection projection = mapView.getProjection();
Paint paint = new Paint();
paint.setARGB(250, 255, 0, 0);.............
View 1 Replies
View Related
Jun 13, 2009
Is it possible to use "stretchable" graphic as pin in ItemizedOverlay? If not how can I draw NinePatchDrawable on Canvas?
View 4 Replies
View Related
Jan 31, 2010
I've seen all the posts about using setLastFocusedIndex(-1).
I've tried that but my app is still crashing.
CODE:...............
View 2 Replies
View Related
Nov 15, 2010
This does not refer to anywhere in my code at all.
How do I go about getting to the bottom of it?
CODE:..........................
Here is the draw method of the ItemizedOverlay
CODE:..........................
I now print out the stacktrace and no difference!
View 1 Replies
View Related
Oct 24, 2009
I want to draw 20 pins on a MapActivity. Each pin has a small pin image, but I have to dynamically overlay a small bit of text over each pin at runtime.
Looks like I have two options:
#1) Itemized Overlay This is the suggested method. I put all my pins in one ItemizedOverlay object, and that counts as a single Overlay object for my MapView.
#2) One Overlay per pin Create a separate Overlay instance for each pin I need to render.
The problem I see with using method #1 is that you need to set a drawable for the item. This would mean that I need to create 20+20 (one for focused/non-focused state each) bitmaps and keep them in memory for the duration of my app. On the other hand, Overlay lets you override the draw method so I can do the simple compositing at runtime.
The other issue with Itemized Overlay - although it handles focus for you - does it move the focused item to the front of the z-order when selected?
View 2 Replies
View Related
Oct 31, 2010
I'm having some troubles with displaying ItemizedOverlay(s) on a map.
Here I extracted a simplified example of what I need to do.
Here's my Map class:
CDE:........
I followed the guide provided by google to extends the ItemizedOverlay class
CODE:...................
As it is clear from the code I need to update at fixed times a map UI with possibly new positions to do so I'm using a timer, but I think I might fall in some kind of thread issues I don't know how to handle, since when running a test I can see in the Log what happens but no marker is drawn on the map.
View 1 Replies
View Related
Sep 23, 2010
I have an itemizedOverlay extended and I want to increase the hit detection on the OverLayItem's if this is possible?
View 1 Replies
View Related
Feb 15, 2010
I'm using Google maps. I put the markers on map and my inherited ItemizedOverlay overrides onTap() method.
Markers are 32x32 images.
However, I can tap quite a bit away from the marker and still receive the event. This becomes a problem when markers are close to each other.
View 2 Replies
View Related
Jun 15, 2010
I have a MapView where I would like to be able to tap the map to create a new item at that location if there is no item there, or display the info about the item if there is.
I tried overriding both the onTap(int) and onTap(GeoPoint, MapView) methods but apparently if the second method is overridden the first never gets called (commenting one or the other lets each one work as I expected).
I thought about just checking if an item was at the location, but there doesn't seem to be any handy methods available to do that (other than iterating through the list of items and checking each manually).
View 17 Replies
View Related
Feb 4, 2010
When I add a new item to my ItemizedOverlay the onTap display I have set appears X times, where X is equal to the number of items that I added. So for example, if I add one item and tap it, it the onTap method gets called once, and in the LogCat I get:
02-04 23:28:56.188: INFO/NotificationService(52): enqueueToast pkg=android.mapit callback=android.app.ITransientNotification$Stub $Proxy@4394c100 duration=0
If I add a second item and click ANY of the other items, the onTap method gets called twice and I get the following in LogCat:
CODE:.....................
If I add a third item and click ANY of the other items, the onTap method gets called three times and I get the following in LogCat:
CODE:...................................
Any idea why this would occur? I'm running into issues with it affecting other things like removal of items.
View 2 Replies
View Related
Jul 3, 2009
I have a method in my ItemizedOverlay class which takes an object as a parameter and depending on it's certain values returns an appropriate icon. What's the best way to access the drawable resource from within ItemizedOverlay as you can't access it directly like in an activity? The only idea I have for now is to pass the resources as a second argument...
View 3 Replies
View Related
Jul 6, 2009
I have the following exception that occurs I don't really know in which circumstances.
I'm just trying to add an overlay to may viewMap, and I don't have anything special in my classes. The most strange thing is that it worked for a while, then it broken again when I changed my image!
CODE:............................
View 4 Replies
View Related
Apr 14, 2010
I am trying to display one png (drawable) on a map in about 300 points. I am retrieving the coordinates from a Sqlite table, dumping them in a cursor. When I try to display them by parsing through the cursor, it takes for ever for the images to be drawn, about .5 second per image. I find that to be suspiciously slow, so some insight on how I can increase performance would help. Here is the snippet of my code that does the rendering:
while (!mFlavorsCursor.isAfterLast())
{
Log.d("cursor",""+(i++));
point = new GeoPoint(
(int)(mFlavorsCursor.getFloat(mFlavorsCursor.getColumnIndex(DataBaseHelper.KEY_LATITUDE))*1000000),
(int)(mFlavorsCursor.getFloat(mFlavorsCursor.getColumnIndex(DataBaseHelper.KEY_LONGITUDE))*1000000));
overlayitem = new OverlayItem(point, "", "");
itemizedoverlay.addOverlay(overlayitem);
itemizedoverlay.doPopulate();
mFlavorsCursor.moveToNext();
}
mapOverlays.add(itemizedoverlay);
I tried to isolate all the steps and it looks like the slow one is this: itemizedoverlay.doPopulate(); This is a public method in my class that extends ItemizedOverlay that runs the private populate() method.
View 1 Replies
View Related
Jun 7, 2010
In the description of how to add a list of options to an AlertDialog the official Android documentation alludes to saving a users preferences with one of the "data storage techniques." The examples assume the AlertDialog has been spawned within an Activity class.
In my case I've created a class that extends ItemizedOverlay. This class overrides the onTap method and uses an AlertDialog to prompt the user to make a multi-choice selection. I would like to capture and persist the selections for each OverlayItem they tap on.
The below code is the onTap method I've written. It functions as written but doesn't yet do what I'd hope. I'd like to capture and persist each selection made by the user to be used later. How do I do that? Is using an AlertDialog in this manner a good idea? Are there better options?
CODE:.......................
View 2 Replies
View Related
Jun 21, 2010
I want to have a elmenent with a 2 color border outline. I can do a single color outline using the element, but this only allows me to draw a single line. I tried using 2 elements within my but that didnt work either. Is there a way to either draw a shape within a shape or draw 2 lines around my shape (which has rounded corners btw).
View 3 Replies
View Related
Apr 16, 2009
I followed the steps in document to display MapView. But blank grid is displayed instead of google map. My code...
View 2 Replies
View Related
May 3, 2009
I've just downloaded the Cupcake SDK. I'm afraid I can't find MapView anymore...
View 5 Replies
View Related
Sep 28, 2009
My problem is my MapView becoming very laggy and so non-responsive at times, that Android thinks its hit deadlock and tries to close it.
I am adding 60 overlays to the map view and i originally thought that the icon size may be causing the problem by using up all the memory. When i decreased the overlay icon size, it did improve things, though it is still to slow to be usable. Has anyone experienced anything similar and have a workaround? There may be a better way of doing it other then extending the Hello MapView example.
View 8 Replies
View Related
Feb 17, 2010
How to get MapView API in android?
View 2 Replies
View Related