Search Results

Search found 271 results on 11 pages for 'mapview'.

Page 1/11 | 1 2 3 4 5 6 7 8 9 10 11  | Next Page >

  • Android: Cannot cast from View to MapView

    - by Gaz
    I'm trying to run the Android MapView example, and am getting a 'Cannot cast from View to MapView' error in Eclipse. My layout is as follows <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/mainlayout" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <com.google.android.maps.MapView android:id="@+id/mapview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:clickable="true" android:apiKey="0jwi0saLYCPGfO-t7glg5bQoBz7jVKWCcgyQWQA" /> <LinearLayout android:id="@+id/zoomview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@id/mapview" android:layout_centerHorizontal="true" /> </RelativeLayout> and the Activity code is package org.gaz.mapapp; import android.os.Bundle; import android.view.View; import android.widget.LinearLayout; import android.widget.ZoomControls; import com.google.android.maps.*; public class MapView extends MapActivity { LinearLayout linearLayout; MapView mapView; ZoomControls mZoom; public void onCreate(Bundle savedInstance) { linearLayout = (LinearLayout) findViewById(R.id.mainlayout); mapView = (MapView) findViewById(R.id.mapview); mZoom = (ZoomControls) mapView.getZoomControls(); } @Override protected boolean isRouteDisplayed() { // TODO Auto-generated method stub return false; } } The error is caused by the line mapView = (MapView) findViewById(R.id.mapview); Can anybody offer an suggestions as to a fix? Cheers, Gaz.

    Read the article

  • Show MapView on PopupWindow

    - by Ali Nadi
    I want to show MapView on PopupWindow and get error when press-on Map. Please help! Liste.java MapView mapView; View view; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.liste); LayoutInflater mInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = mInflater.inflate(R.layout.pop_up, (ViewGroup) findViewById(R.id.popup_element), false); mapView = (MapView) view.findViewById(R.id.mapview_popup); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View v, int position, long id) { initiatePopupWindow(earthQuakeList.get(position)); } }); } private void initiatePopupWindow(EqData data) { try { mapView.setBuiltInZoomControls(true); List<Overlay> mapOverlays = mapView.getOverlays(); Drawable marker = this.getResources().getDrawable(R.drawable.marker1); HaritaOverlay itemizedoverlay = new HaritaOverlay(marker, this); Coordination coord = data.getCoordination(); GeoPoint point = new GeoPoint( (int)coord.latitude, (int)coord.longitude); OverlayItem overlayitem = new OverlayItem(point, data.lokasyon, data.name); itemizedoverlay.addOverlay(overlayitem); mapOverlays.add(itemizedoverlay); Display display = getWindowManager().getDefaultDisplay(); pw = new PopupWindow(view, display.getWidth(), display.getHeight()/2, true); // display the popup in the center pw.showAtLocation(view, Gravity.CENTER, 0, display.getHeight()/2); } catch (Exception e) { e.printStackTrace(); } } pop_up.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:baselineAligned="false" android:orientation="vertical" android:weightSum="540" android:id="@+id/popup_element" > ... <LinearLayout android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="440" > <com.google.android.maps.MapView android:id="@+id/mapview_popup" android:layout_width="fill_parent" android:layout_height="fill_parent" android:apiKey="@string/ApiMapKey" android:clickable="true" /> </LinearLayout> Error 07-23 17:36:28.820: E/MapActivity(12413): Couldn't get connection factory client 07-23 17:36:37.760: E/AndroidRuntime(12413): FATAL EXCEPTION: main 07-23 17:36:37.760: E/AndroidRuntime(12413): android.view.WindowManager$BadTokenException: Unable to add window -- token android.view.ViewRoot$W@40590b70 is not valid; is your activity running? 07-23 17:36:37.760: E/AndroidRuntime(12413): at android.view.ViewRoot.setView(ViewRoot.java:528) 07-23 17:36:37.760: E/AndroidRuntime(12413): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177) 07-23 17:36:37.760: E/AndroidRuntime(12413): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91) 07-23 17:36:37.760: E/AndroidRuntime(12413): at android.view.Window$LocalWindowManager.addView(Window.java:465) 07-23 17:36:37.760: E/AndroidRuntime(12413): at android.widget.ZoomButtonsController.setVisible(ZoomButtonsController.java:370) 07-23 17:36:37.760: E/AndroidRuntime(12413): at com.google.android.maps.MapView.displayZoomControls(MapView.java:1053) 07-23 17:36:37.760: E/AndroidRuntime(12413): at com.google.android.maps.MapView$1.onDown(MapView.java:341) 07-23 17:36:37.760: E/AndroidRuntime(12413): at com.google.android.maps.GestureDetector.onTouchEvent(GestureDetector.java:488) 07-23 17:36:37.760: E/AndroidRuntime(12413): at com.google.android.maps.MapView.onTouchEvent(MapView.java:683) 07-23 17:36:37.760: E/AndroidRuntime(12413): at android.view.View.dispatchTouchEvent(View.java:3901) 07-23 17:36:37.760: E/AndroidRuntime(12413): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903) 07-23 17:36:37.760: E/AndroidRuntime(12413): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:869) 07-23 17:36:37.760: E/AndroidRuntime(12413): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:869) 07-23 17:36:37.760: E/AndroidRuntime(12413): at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2200) 07-23 17:36:37.760: E/AndroidRuntime(12413): at android.view.ViewRoot.handleMessage(ViewRoot.java:1884) 07-23 17:36:37.760: E/AndroidRuntime(12413): at android.os.Handler.dispatchMessage(Handler.java:99) 07-23 17:36:37.760: E/AndroidRuntime(12413): at android.os.Looper.loop(Looper.java:130) 07-23 17:36:37.760: E/AndroidRuntime(12413): at android.app.ActivityThread.main(ActivityThread.java:3835) 07-23 17:36:37.760: E/AndroidRuntime(12413): at java.lang.reflect.Method.invokeNative(Native Method) 07-23 17:36:37.760: E/AndroidRuntime(12413): at java.lang.reflect.Method.invoke(Method.java:507) 07-23 17:36:37.760: E/AndroidRuntime(12413): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847) 07-23 17:36:37.760: E/AndroidRuntime(12413): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605) 07-23 17:36:37.760: E/AndroidRuntime(12413): at dalvik.system.NativeStart.main(Native Method)

    Read the article

  • Mapview getLatitudeSpan and getLongitudeSpan not working

    - by janfsd
    Hi! Sometimes when trying to get the Latitude span or Longitude span of a mapview with getLatitudeSpan() and getLongitudeSpan() I get 0 and 360*1E6 respectively. This doesn't happen always but it is a problem, has anybody got this problem? Any workarounds? I tried using getProjection() too but I get the same problem. Here is the piece of code: MapView mapView = (MapView) findViewById(R.id.mapview); int lat = mapView.getLatitudeSpan(); // sometimes returns 0 int long = mapView.getLongitudeSpan(); // sometimes returns 360*1E6

    Read the article

  • IllegalArgumentException: width and height must be > 0 during zoomOut in Google MapView

    - by Janusz
    I'm trying to zoom in on a Google MapView on step in the oncreateMethod of my Activity. Everytime I try to zoom the map via the mapController I get an IllegalArgumentException: 04-15 10:16:51.012: ERROR/AndroidRuntime(528): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.innomos.couponimo.android.client/com.innomos.couponimo.android.client.ui.showstores.StoreMap}: java.lang.IllegalArgumentException: width and height must be > 0 This Exception is thrown if I call the zoomOut or zoomIn function of MapController. Sadly the zoomIn function I'm using does not take any arguments. The onCreateMethod where I'm calling the zoom functions looks like this: mapView = (MapView) findViewById(R.id.map); mapView.setBuiltInZoomControls(true); MapController mapController = mapView.getController(); mapController.zoomIn(); I'm a little bit at loss here because I'm doing nothing special. The whole stacktrace is: 04-15 10:16:51.012: ERROR/AndroidRuntime(528): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.innomos.couponimo.android.client/com.innomos.couponimo.android.client.ui.showstores.StoreMap}: java.lang.IllegalArgumentException: width and height must be > 0 04-15 10:16:51.012: ERROR/AndroidRuntime(528): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401) 04-15 10:16:51.012: ERROR/AndroidRuntime(528): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417) 04-15 10:16:51.012: ERROR/AndroidRuntime(528): at android.app.ActivityThread.access$2100(ActivityThread.java:116) 04-15 10:16:51.012: ERROR/AndroidRuntime(528): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 04-15 10:16:51.012: ERROR/AndroidRuntime(528): at android.os.Handler.dispatchMessage(Handler.java:99) 04-15 10:16:51.012: ERROR/AndroidRuntime(528): at android.os.Looper.loop(Looper.java:123) 04-15 10:16:51.012: ERROR/AndroidRuntime(528): at android.app.ActivityThread.main(ActivityThread.java:4203) 04-15 10:16:51.012: ERROR/AndroidRuntime(528): at java.lang.reflect.Method.invokeNative(Native Method) 04-15 10:16:51.012: ERROR/AndroidRuntime(528): at java.lang.reflect.Method.invoke(Method.java:521) 04-15 10:16:51.012: ERROR/AndroidRuntime(528): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791) 04-15 10:16:51.012: ERROR/AndroidRuntime(528): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549) 04-15 10:16:51.012: ERROR/AndroidRuntime(528): at dalvik.system.NativeStart.main(Native Method) 04-15 10:16:51.012: ERROR/AndroidRuntime(528): Caused by: java.lang.IllegalArgumentException: width and height must be > 0 04-15 10:16:51.012: ERROR/AndroidRuntime(528): at android.graphics.Bitmap.nativeCreate(Native Method) 04-15 10:16:51.012: ERROR/AndroidRuntime(528): at android.graphics.Bitmap.createBitmap(Bitmap.java:468) 04-15 10:16:51.012: ERROR/AndroidRuntime(528): at com.google.android.maps.ZoomHelper.createSnapshot(ZoomHelper.java:305) 04-15 10:16:51.012: ERROR/AndroidRuntime(528): at com.google.android.maps.ZoomHelper.doZoom(ZoomHelper.java:137) 04-15 10:16:51.012: ERROR/AndroidRuntime(528): at com.google.android.maps.ZoomHelper.doZoom(ZoomHelper.java:126) 04-15 10:16:51.012: ERROR/AndroidRuntime(528): at com.google.android.maps.MapView.doZoom(MapView.java:1459) 04-15 10:16:51.012: ERROR/AndroidRuntime(528): at com.google.android.maps.MapView.doZoom(MapView.java:1468) 04-15 10:16:51.012: ERROR/AndroidRuntime(528): at com.google.android.maps.MapController.zoomIn(MapController.java:427) 04-15 10:16:51.012: ERROR/AndroidRuntime(528): at com.innomos.couponimo.android.client.ui.showstores.StoreMap.onCreate(StoreMap.java:58) 04-15 10:16:51.012: ERROR/AndroidRuntime(528): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123) 04-15 10:16:51.012: ERROR/AndroidRuntime(528): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364) 04-15 10:16:51.012: ERROR/AndroidRuntime(528): ... 11 more

    Read the article

  • Removing and then adding MKAnnotations to a MapView is leaving me with a blank MapView

    - by Chris McCall
    A followup to this quesiton: http://stackoverflow.com/questions/2944581/forcing-reload-of-view-when-returning-from-flipsideview-of-utility-application When returning from the flipside view, I'm calling NSArray *annotations = [NSArray arrayWithArray:[mapView annotations]]; [mapView removeAnnotations:annotations]; To remove all the pins from the map (let me know if this isn't the best way to do this). Then: for(Hole *hole in fetchedObjects) { double latitude = [hole.Latitude doubleValue]; cord.latitude = latitude; double longitude = [hole.Longitude doubleValue]; cord.longitude = longitude; WellPlaceMark *placemark = [[WellPlaceMark alloc] initWithCoordinate:cord withWellType:[NSString stringWithString: hole.WellType]]; [mapView addAnnotation:placemark]; } Plus: - (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{ MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"]; if ([annotation isKindOfClass:[MKUserLocation class]]) return nil; if([annotation isKindOfClass:[WellPlaceMark class]]) { ... } annView.animatesDrop=FALSE; return annView; } All of this code seems to be called in the debugger, but when it's finished, I'm presented with a blank map. I've tried zooming out and the pins are nowhere. The map loads up fine on the first try, but once I call removeAnnotations, they never return.

    Read the article

  • Close balloon showed on MapView

    - by Pich
    Hi, I have a MapView with an ItemizedOverlay and a bunch of OverlayItem:s. When an OverlayItem is tapped on custom layout balloon is displayed on MapView. I can add a close button that hides the balloon layout. But how can I close the balloon if the user tap:s on the map outside the balloon? I have an OnTouchListener on the MapView, but how can I from this localize the open balloon layout and hide it? /P

    Read the article

  • MapView tiles loading in Android

    - by Pich
    In the Maps application (at least version 5) for Android the tiles are loading in a different way, than when using a MapView in my own application, when for example zooming in or out. In the MapView displays a gray checkered image until the tile is fully loaded an than the map is displayed. In Maps application this it not the case all the time. Tiles that are not fully loaded are still showing a map but it is blurry. The Maps application way of showing the map when zooming is much prettier for the eye. Is it possible to have this "feature" in a MapView in my own application as well? Best regards P

    Read the article

  • Get info on a mapview selected annotation

    - by rson
    I have annotations on a mapview and a callout with a button on each. What I need to do is grab properties from this callout, ie. the title, but logging this line: NSLog(@"%@", mapView.selectedAnnotations); returns <AddressAnnotation: 0x1bdc60> which obviously gives me no useful info... My question is, how can I access the properties of a selected annotation callout?

    Read the article

  • iPhone mapView / mapKit using removeAnnotation & addAnnotation results in memory leak?

    - by user266618
    To update the location of a GPS indicator on mapView... [mapView removeAnnotation:myGpsAnnotation]; [myGpsAnnotation release]; myGpsAnnotation = nil; myGpsAnnotation = [[MapLocationAnnotation alloc] initWithCoordinate:region.center annotationType:MapAnnotationTypeGps title:MAP_ANNOTATION_TYPE_GPS]; [mapView addAnnotation:myGpsAnnotation]; ...I see net memory slowly climbing in Instruments (simulator). No "Leak" blip, but "Net Bytes" and "# Net" slowly incrementing... unless this code is commented out. So I'm 100% certain this is the offending code. BUT if I do the following... [mapView removeAnnotation:myGpsAnnotation]; [myGpsAnnotation release]; myGpsAnnotation = nil; myGpsAnnotation = [[MapLocationAnnotation alloc] initWithCoordinate:region.center annotationType:MapAnnotationTypeGps title:MAP_ANNOTATION_TYPE_GPS]; [mapView addAnnotation:myGpsAnnotation]; [mapView removeAnnotation:myGpsAnnotation]; [mapView addAnnotation:myGpsAnnotation]; [mapView removeAnnotation:myGpsAnnotation]; [mapView addAnnotation:myGpsAnnotation]; ...then the "Net Bytes" and "# Net" increase much faster. Is it possible this isn't my mistake, and I'm trying to track down a leak in MapKit? Am I really leaking memory? Again, nothing appears under "Leaks", but then I don't see why Net values would be continually climbing. Thanks for any help, -Gord

    Read the article

  • Performance issue on Android's MapView Navigation-App

    - by poeschlorn
    Hey Guys, I've got a question on making an navigation app more faster and more stable. The basic layer of my app is a simple mapview, covered with several overlays (2 markers for start and destination and one for the route). My idea is to implement a thread to display the route, so that the app won't hang up during the calculation of a more complex route (like it does right now). After implementing the thread there are no updates shows any more, maybe you can help me with a short glance at an excerpt of my code below: private class MyLocationListener implements LocationListener { @Override public void onLocationChanged(Location loc) { posUser = new GeoPoint((int) (loc.getLatitude() * 1E6), (int) (loc .getLongitude() * 1E6)); new Thread(){ public void run(){ mapView.invalidate(); // Erase old overlays mapView.getOverlays().clear(); // Draw updated overlay elements and adjust basic map settings updateText(); if(firstRefresh){ adjustMap(); firstRefresh = false; } getAndPaintRoute(); drawMarkers(); } }; } Some features have been summarized to a method like "drawMarkers()" or "updateText()"...(they don't need any more attention ;-))

    Read the article

  • MapView without Zoom Levels Android

    - by RyanInBinary
    I'm using the MapView object for my app and it's working really well. But I noticed that it "locks" to zoom levels, even if you don't use them. For instance, if you pinch to zoom and barely do it, the view will "snap" either forward or backward to whatever the closest zoom level is. The native google maps application does not do this at all. You can barely pinch, and it'll accept it (there are no 'hard' zoom levels built in). How can I get my mapview to mirror that?

    Read the article

  • Adding visible "Markers" to represent Geopoints to a MapView using ItemizedOverlay in Android

    - by LordSnoutimus
    Hello, I am building an application which stores GPS locations in a SQLite database and then outputs the data onto a MapView using an Overlay by drawing a red line between the points. I want to be able to show graphical markers (images) for each of these points as well as the red line. My code is as follows: public class MyOverlay extends ItemizedOverlay { // private Projection projection; private Paint linePaint; private Vector points; public MyOverlay(Drawable defaultMarker) { super(defaultMarker); points = new Vector<GeoPoint>(); //set colour, stroke width etc. linePaint = new Paint(); linePaint.setARGB(255, 255, 0, 0); linePaint.setStrokeWidth(3); linePaint.setDither(true); linePaint.setStyle(Style.FILL); linePaint.setAntiAlias(true); linePaint.setStrokeJoin(Paint.Join.ROUND); linePaint.setStrokeCap(Paint.Cap.ROUND); } public void addPoint(GeoPoint point) { populate(); points.addElement(point); } //public void setProjection(Projection projection) { // this.projection = projection; // } public void draw(Canvas canvas, MapView view, boolean shadow) { populate(); int size = points.size(); Point lastPoint = new Point(); if(size == 0) return; view.getProjection().toPixels(points.get(0), lastPoint); Point point = new Point(); for(int i = 1; i<size; i++){ view.getProjection().toPixels(points.get(i), point); canvas.drawLine(lastPoint.x, lastPoint.y, point.x, point.y, linePaint); lastPoint = point; } } @Override protected OverlayItem createItem(int arg0) { // TODO Auto-generated method stub return null; } @Override public int size() { // TODO Auto-generated method stub return 0; } } What would be the easiest way to implement adding markers for each GeoPoint? Thanks

    Read the article

  • Getting coordinates when clicking anywhere on a MapView

    - by DixieFlatline
    I just cant get this working. I tried using the code below with onTouchEventand and it doesn't work. If i return true at the end of the method, i get the toast with the coordinates but can't move a map, and if i return false, i can move a map but cant display a toast after the user clicks on a map. If i get it right, the other onTap method is used only for clicking on a overlays. Has anybody figured this thiing out? public boolean onTouchEvent(MotionEvent arg0, MapView arg1) { //super.onTouchEvent(arg0); int akcija = arg0.getAction(); if(akcija == MotionEvent.ACTION_UP){ if(!premik) { Projection proj = mapView.getProjection(); GeoPoint loc = proj.fromPixels((int)arg0.getX(), (int)arg0.getY()); String sirina=Double.toString(loc.getLongitudeE6()/1000000); String dolzina=Double.toString(loc.getLatitudeE6()/1000000); Toast toast = Toast.makeText(getApplicationContext(), "Širina: "+sirina+" Dolzina: "+dolzina, Toast.LENGTH_LONG); toast.show(); } } else if (akcija == MotionEvent.ACTION_DOWN){ premik= false; } else if (akcija== MotionEvent.ACTION_MOVE){ premik = true; } return false; //return super.onTouchEvent(arg0); }

    Read the article

  • You are only allowed to have a single MapView in a MapActivity

    - by ProNeticas
    I have a function that shows a map page so I can get the user to choose their current location. But if you run this function twice it crashes the App with the Single MapView in a MapActivity error (i.e. opening that settings view again). public void showMapSetterPage(View v) { Log.i(DEBUG_TAG, "Settings screen, set map center launched"); // Set which view object we fired off from set_pv(v); // Show Map Settings Screen setContentView(R.layout.set_map_center); // Initiate the center point map if (mapView == null) { mapView = (MapView) findViewById(R.id.mapview); } mapView.setLongClickable(true); mapView.setStreetView(true); mapView.setBuiltInZoomControls(false); mapView.setSatellite(false); mapController = mapView.getController(); mapController.setZoom(18); LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Location location = lm .getLastKnownLocation(LocationManager.GPS_PROVIDER); int lat = (int) (location.getLatitude() * 1E6); int lng = (int) (location.getLongitude() * 1E6); Log.i(DEBUG_TAG, "The LAT and LONG is: " + lat + " == " + lng); point = new GeoPoint(lat, lng); // mapController.setCenter(point); mapController.animateTo(point); } So I have a button that shows this View and onClick="showMapSetterPage". But if you go back to the settings screen out of the map and click the button again I get this error: 03-06 20:55:54.091: ERROR/AndroidRuntime(28014): Caused by: java.lang.IllegalStateException: You are only allowed to have a single MapView in a MapActivity How can I delete the MapView and recreate it?

    Read the article

  • Android MapView: Disable auto zoom

    - by Ola Andersson
    Hi. I have made an Android app that shows a MapView with two overlays, one MyLocationOverlay and one custom overlay. I am programmatically zooming and panning to what I want the map to show. It also auto pans to my current location. The auto pan is moving the map away from what I want to show. So my question is simply: How can I disable the auto pan? Thanks, Ola

    Read the article

  • Android "Hello, MapView" Tutorial - Map Tiles Do Not Load

    - by Onyx
    I am new to Android software development and new to this site. I am hoping someone might have some experience with the problem I am having. I've been following the Hello, MapView tutorial in order to not only learn the Android framework, but also the Google Maps library. I've tried my best to implement things exactly as the tutorial has instructed. My problem is that the application does load in my emulator (or even on my phone for that matter), but the map tiles do not load. Searching Google I found a post by someone else on another site having the same issue, but his/her problem was that the important elements added to the AndroidManifest.xml file were not in the right order. I double-checked this in mine, but everything seems to be right. So, I am not sure what the issue is and was hoping others have seen this before. I can provide any snippets of code, if that would help. Thank you.

    Read the article

  • Android - drawing path as overlay on MapView

    - by Rabas
    Hello, I have a class that extends Overlay and implemments Overlay.Snappable. I have overriden its draw method: @Override public void draw(Canvas canvas, MapView mv, boolean shadow) { Projection projection = mv.getProjection(); ArrayList<GeoPoint> geoPoints = new ArrayList<GeoPoint>(); //Creating geopoints - ommited for readability Path p = new Path(); for (int i = 0; i < geoPoints.size(); i++) { if (i == geoPoints.size() - 1) { break; } Point from = new Point(); Point to = new Point(); projection.toPixels(geoPoints.get(i), from); projection.toPixels(geoPoints.get(i + 1), to); p.moveTo(from.x, from.y); p.lineTo(to.x, to.y); } Paint mPaint = new Paint(); mPaint.setStyle(Style.FILL); mPaint.setColor(0xFFFF0000); mPaint.setAntiAlias(true); canvas.drawPath(p, mPaint); super.draw(canvas, mv, shadow); } As you can see, I make a list of points on a map and I want them to form a polygonal shape. Now, the problem is that when I set paint style to be FILL or FILL_AND_STROKE nothing shows up on the screen, but when I set it to be just stroke, and set stroke width, it acctually draws what it is supposed to draw. Now, I looked for solution, but nothing comes up. Can you tell me if I something missed to set in the code itself, or are there some sorts of constraints when drawing on Overlay canvases? Thanks

    Read the article

  • Rotate MapView in Android

    - by Matthew B.
    I am writing an Android app where one of the features is that the map will rotate according to the compass (i.e. if the phone is pointing east, the map will be oriented so that the east side of the map is on top). Previous answers that I have found suggested over writing the onDraw() method in mapView, however, the api changed the method to final so it cannot be overwritten. As a result I have tried to overwrite the dispatchDraw() method like so: Note: -compass is a boolean that if true, rotate the view -bearing is a float variable that has the degrees that the view should rotate protected void dispatchDraw(Canvas canvas) { canvas.save(); if (compass) { final float w = this.getWidth(); final float h = this.getHeight(); final float scaleFactor = (float)(Math.sqrt(h * h + w * w) / Math.min(w, h)); final float centerX = w / 2.0f; final float centerY = h / 2.0f; canvas.rotate(bearing, centerX, centerY); canvas.scale(scaleFactor, scaleFactor, centerX, centerY); } super.dispatchDraw(canvas); canvas.restore(); }

    Read the article

  • launching mapview from main activity (button)

    - by arc
    Hi all. Going round in circles here i think. I have an activity called Locate; public class Locate extends Activity { public static String lat; public static String lon; public static String number; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.locate); final Button buttonMaps = (Button) findViewById(R.id.ButtonMaps); buttonMaps.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Toast.makeText(getBaseContext(), "Button Pressed", Toast.LENGTH_SHORT).show(); try { Intent i = new Intent(getBaseContext(), displayMap.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); } catch (ActivityNotFoundException e) { Toast.makeText(getBaseContext(), "Activity Not Found", Toast.LENGTH_SHORT).show(); } }}); // Toast.makeText(getBaseContext(), "lat: " + lat + " long: " + lon + " from: " + testname, Toast.LENGTH_LONG).show(); } If I make the displayMap class into a normal Activity, and just have display a toast message confirming it has loaded - then it works fine. If i do this though; public class displayMap extends MapActivity { /** Called when the activity is first created. */ public void onCreate() { setContentView(R.layout.displaymap); Toast.makeText(getBaseContext(), "Display Map", Toast.LENGTH_SHORT).show(); } @Override protected boolean isRouteDisplayed() { // TODO Auto-generated method stub return false; } } Then as soon as I click the Button, I get a force close. I have the correct 'uses-library' tag in my manifest; <application android:icon="@drawable/icon" android:label="@string/app_name"> <uses-library android:name="com.google.android.maps" /> I don't get what it just force closes everytime i try and load it. If I make this my onClick handler then it will fire up a working googlemaps/default mapview public void onClick(View v) { Toast.makeText(getBaseContext(), "Button Pressed", Toast.LENGTH_SHORT).show(); Uri uri=Uri.parse("geo:"+Locate.lat+","+Locate.lon); StartActivity(new Intent(Intent.ACTION_VIEW, uri)); } But that is not what I am trying to do, I want my own - so that I can add overlays etc to it. But it does prove that the permission are set correctly and that the lib is there. The logcat error when the app FCs is a Unexpected DEX error. Can anyone point in the right direction here?

    Read the article

  • Android - MapView contained within a Listview

    - by Ryan
    Hello, Currently I am trying to place a MapView within a ListView. Has anyone had any success with this? Is it even possible? Here is my code: ListView myList = (ListView) findViewById(android.R.id.list); List<Map<String, Object>> groupData = new ArrayList<Map<String, Object>>(); Map<String, Object> curGroupMap = new HashMap<String, Object>(); groupData.add(curGroupMap); curGroupMap.put("ICON", R.drawable.back_icon); curGroupMap.put("NAME","Go Back"); curGroupMap.put("VALUE","By clicking here"); Iterator it = data.entrySet().iterator(); while (it.hasNext()) { //Get the key name and value for it Map.Entry pair = (Map.Entry)it.next(); String keyName = (String) pair.getKey(); String value = pair.getValue().toString(); if (value != null) { //Add the parents -- aka main categories curGroupMap = new HashMap<String, Object>(); groupData.add(curGroupMap); //Push the correct Icon if (keyName.equalsIgnoreCase("Phone")) curGroupMap.put("ICON", R.drawable.phone_icon); else if (keyName.equalsIgnoreCase("Housing")) curGroupMap.put("ICON", R.drawable.house_icon); else if (keyName.equalsIgnoreCase("Website")) curGroupMap.put("ICON", R.drawable.web_icon); else if (keyName.equalsIgnoreCase("Area Snapshot")) curGroupMap.put("ICON", R.drawable.camera_icon); else if (keyName.equalsIgnoreCase("Overview")) curGroupMap.put("ICON", R.drawable.overview_icon); else if (keyName.equalsIgnoreCase("Location")) curGroupMap.put("ICON", R.drawable.map_icon); else curGroupMap.put("ICON", R.drawable.icon); //Pop on the Name and Value curGroupMap.put("NAME", keyName); curGroupMap.put("VALUE", value); } } curGroupMap = new HashMap<String, Object>(); groupData.add(curGroupMap); curGroupMap.put("ICON", R.drawable.back_icon); curGroupMap.put("NAME","Go Back"); curGroupMap.put("VALUE","By clicking here"); //Set up adapter mAdapter = new SimpleAdapter( mContext, groupData, R.layout.exp_list_parent, new String[] { "ICON", "NAME", "VALUE" }, new int[] { R.id.photoAlbumImg, R.id.rowText1, R.id.rowText2 } ); myList.setAdapter(mAdapter); //Bind the adapter to the list Thanks in advance for your help!!

    Read the article

  • Android Mapview panning and zooming too slow........

    - by Pratap S
    I've developed a GPS app in which i record the user roots and show it on the map.......but Panning around on the map when reviewing my route is painfully slow, it takes at least 4 or 5 seconds for the map to respond the finger swipes...... I've overridden the onDraw() method and drawing the lines to show the routes......is there any better way to do this so that panning becomes faster as in "MyTracks"........... Thank you all..... Pratap S.

    Read the article

  • Weird Overlay draw behaviour when zooming in the MapView [android]

    - by Itsik
    I've extended Overlay and implemented draw() in order to draw some stuff onto the map. When zooming is done through mapController.zoomIn() (called when doubleTapping the map), the overlay is drawn properly onto the map. BUT whenever I zoom in/out with the built in zoom controller, the overlay is not drawn properly and panning the map is needed to get the overlay refreshed.

    Read the article

  • How do I set streetView in my mapview

    - by John
    I an working on an android project whereby i need to set my map to zoom in and show a more detailed view of my map, like the streets of where i want my coordinates to triangulate. The problem is in Mapview class, setStreetView is deprecated, wat is the alternative? This is how setStreetView looks when i use it. package com.HelloMapView; import java.util.List; import com.google.android.maps.GeoPoint; import com.google.android.maps.MapActivity; import com.google.android.maps.MapController; import com.google.android.maps.MapView; import com.google.android.maps.Overlay; import com.google.android.maps.OverlayItem; import android.app.Activity; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.widget.LinearLayout; public class HelloMapView extends MapActivity { MapView mapview; LinearLayout linearlayout; List<Overlay> mapOverlay; Drawable drawable; HelloItemizedOverlay itemizedOverlay; @SuppressWarnings("deprecation") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mapview=(MapView)findViewById(R.id.mapview); mapview.setBuiltInZoomControls(true); mapview.setStreetView(true); mapOverlay=mapview.getOverlays(); drawable=this.getResources().getDrawable(R.drawable.androidmarker); itemizedOverlay=new HelloItemizedOverlay(drawable); GeoPoint geoPoint=new GeoPoint(19240000,-99120000); OverlayItem overlayitem=new OverlayItem(geoPoint,"",""); itemizedOverlay.addoverlay(overlayitem); mapOverlay.add(itemizedOverlay); } @Override protected boolean isRouteDisplayed() { // TODO Auto-generated method stub return false; } } this does not work it only shows square boxes with no map at all

    Read the article

  • Draw Circle on the Map once the application gets loaded

    - by TechGeeky
    Background:- In my application what is happening currently- Whenever I am opening the application, In the top half of the android screen, it draws a Map and in the bottom half of the android screen it show's a list view. And then as soon as the location gets changed, it draw's a Circle with the current location as the center of the circle and show's an image at the current location(center of circle). Everything is working fine till here- Problem Statement:- What I want is when the user opens my application, circle should get draw immediately on the Google Map (this is currently not happening, it draw's circle only on the location changed), without waiting for the location to get changed and without any image on the center of circle and then if the location get's changed, take the current location as the center of circle and draw the circle with an image at the center of circle. And this is my below code which fulfills the scenario that I mentioned in my Background- How can I make this code to work the way I wanted to? hope I am clear enough in my question. Any suggestions will be appreciated. @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mapView = (MapView) findViewById(R.id.mapView); listView = (ListView) findViewById(R.id.mylist); locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); locationListener = new GPSLocationListener(mapView); locationManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 35000, 10, locationListener); mapView.setStreetView(true); mapView.setBuiltInZoomControls(true); mapController = mapView.getController(); mapController.setZoom(14); } Location Update class where I am sending the request to Overlay to draw the circle private class GPSLocationListener implements LocationListener { MapOverlay mapOverlay; public GPSLocationListener(MapView mapView) { } @Override public void onLocationChanged(Location location) { if (location != null) { GeoPoint point = new GeoPoint( (int) (location.getLatitude() * 1E6), (int) (location.getLongitude() * 1E6)); mapController.animateTo(point); mapController.setZoom(15); if (mapOverlay == null) { mapOverlay = new MapOverlay(this,android.R.drawable.star_on); List<Overlay> listOfOverlays = mapView.getOverlays(); listOfOverlays.add(mapOverlay); } mapOverlay.setPointToDraw(point); mapView.invalidate(); } } @Override public void onProviderDisabled(String provider) { } @Override public void onProviderEnabled(String provider) { } @Override public void onStatusChanged(String provider, int status, Bundle extras) { } } Class in which circle is getting drawn. class MapOverlay extends Overlay { private GeoPoint pointToDraw; int[] imageNames=new int[6]; private Point mScreenPoints; private Bitmap mBitmap; private Paint mCirclePaint; public MapOverlay(GPSLocationListener gpsLocationListener, int currentUser) { imageNames[0]=currentUser; mCirclePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mCirclePaint.setColor(0x30000000); mCirclePaint.setStyle(Style.FILL_AND_STROKE); mBitmap = BitmapFactory.decodeResource(getResources(),imageNames[0]); mScreenPoints = new Point(); } public void setPointToDraw(GeoPoint point) { pointToDraw = point; } public GeoPoint getPointToDraw() { return pointToDraw; } @Override public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) { super.draw(canvas, mapView, shadow); if (pointToDraw == null) { return true; } mScreenPoints = mapView.getProjection().toPixels(pointToDraw, mScreenPoints); int totalCircle=5; int radius=40; int centerimagesize=35; for (int i = 1; i <= totalCircle; i ++) { canvas.drawCircle(mScreenPoints.x,mScreenPoints.y, i*radius, mCirclePaint); } canvas.drawBitmap(mBitmap, (mScreenPoints.x-(centerimagesize/2)),(mScreenPoints.y-(centerimagesize/2)), null); super.draw(canvas,mapView,shadow); return true; } }

    Read the article

1 2 3 4 5 6 7 8 9 10 11  | Next Page >