Search Results

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

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

  • Strange activity stack behavior when using MapActivity

    - by AndroidDev
    I have the following activity structure in my application A simple "splash screen" activity is started when the application is fired up (let's call it "Splash"). This activity starts the main activity when the user presses a button (I will call it "Main"). Main can in turn start two activities from the menu. The first activity presents a simple form (let's call this one "Form"), the second is a MapActivity that presents a map (it is called "Map"). Main, Form, and Map are declared exactly the same in the manifest: <activity android:name="fully qualified activity class" android:screenOrientation="landscape" android:configChanges="keyboard|keyboardHidden|orientation" > <intent-filter> <action android:name="android.intent.action.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> When Main is active and I start Form and press "back", Main comes up again. Pressing "back" again brings up "Splash". Nothing strange here. Now comes the strange part: when I am in Main, start Map, and press "back", Main comes up as expected. But pressing "back" again just restarts Main. A second press on "back" is needed to bring me back to Splash! So it seems that starting the Map activity somehow results in Main ending up on the activity stack twice while starting the Form activity does not! Both Form and Map are started like this: startActivity(new Intent(this, MyActivity.class)); I don not catch the back key in any activity. Any clues on what is going on or how to debug this?

    Read the article

  • Consequences of isRouteDisplayed() on map view

    - by poeschlorn
    Hi guys, I'm just wondering what consequences the method isRouteDisplayed() has, regarding to functionality of a map view... I have two activities, one displays a route and one doesn't. Is it mandatory to let the first isRouteDisplayed()-Method return true? What effects does it have? greets, poeschlorn

    Read the article

  • map view inside table view cell

    - by kudorgyozo
    Hello, i have another (probably unanswered) question about map views. I have a map view inside a table view cell and i want to disable the table view scrolling if the scrolling begins in the map view. Also the zooming gesture does not function normally. It only functions if the zooming gesture is done horizontally on the iphone display. The same thing happens with swiping gestures. It only affects the map if i swipe the map area horizontally. If i swipe vertically the table view scrolls instead, and i want to disable that. Any ides how to do it?

    Read the article

  • Does the Quick Search Box search the database in Android? how?

    - by Praveen Chandrasekaran
    i have an database with the values of latitude and longitude. i would need to search those values depends on the user input. does the quick search box can search only the database value with the type-to-search feature. Else i want to put a separate EditText and then do the the search process.. if QSB is possible then how to do that? i want to search and drop a pin on the map.. please make a note of it. Any Idea, tutorial and sample codes are most thankful?

    Read the article

  • is this Map API key Problem in Android?

    - by Praveen Chandrasekaran
    Hi folks, I am using 2 map Activities. do i want to register multiple Map APi key for each? Now I am getting this exception: 06-16 16:59:25.048: ERROR/MapActivity(10008): Couldn't get connection factory client I googled about this exception. It concludes that must be a API Key Problem? Is that true? Why it happens? Thanks

    Read the article

  • draw graph in android with dynamically data

    - by Tikam
    In my project i want to draw a graph with dynamically updated data, and data is came from remote device and i update it from my locally sqlite data base. I have to draw a graph dynamically with having two paremeter as horizontally hours of day from {Mid night, 1, 2, ...., 11, Noon, 1 , 11, Mid Night} and vertically parameter as {One , two, Three, Four}. At particular hour i get data value from my sqlite and want to draw it on graph, and any particular hour have different value like "One", "two" etc. and i want to draw graph with hour help. Thanks in advance

    Read the article

  • Couldn't get connection factory client - fighting with Google Maps

    - by iie
    another day another problem, I finally managed to set up correctly google maps on my android application, or at least I thought I've done it, the whole progam starts, it even call the class which should "print" a map, but the only thing I can see is a grid with google label on it [ in the corner ]. I've checked the dalvik monitor and the error E/MapActivity(394): Couldn't get connection factory client occurs. I've find out on stackoverflow website that I should sent a gps signal or sth like this from dalvik monitor, and I've done it. Nothing happend, also I got the api key one more time, but nothing changed. here is map.xml <?xml version="1.0" encoding="utf-8"?> <!-- This file is /res/layout/mapview.xml --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content"> <Button android:id="@+id/zoomin" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="+" android:onClick="myClickHandler" android:padding="12px" /> <Button android:id="@+id/zoomout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="-" android:onClick="myClickHandler" android:padding="12px" /> <Button android:id="@+id/sat" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Satellite" android:onClick="myClickHandler" android:padding="8px" /> <Button android:id="@+id/street" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Street" android:onClick="myClickHandler" android:padding="8px" /> <Button android:id="@+id/traffic" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Traffic" android:onClick="myClickHandler" android:padding="8px" /> <Button android:id="@+id/normal" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Normal" android:onClick="myClickHandler" android:padding="8px" /> </LinearLayout> <com.google.android.maps.MapView android:id="@+id/mapview" android:layout_width="fill_parent" android:layout_height="wrap_content" android:clickable="true" android:apiKey="0zPcz1VYRSpLusufJ2JoL0ffl2uxDMovgpW319w" /> </LinearLayout> here is a MapMapa.java public class MapMapa extends MapActivity { private MapView mapView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.map); mapView = (MapView)findViewById(R.id.mapview); } public void myClickHandler(View target) { switch(target.getId()) { case R.id.zoomin: mapView.getController().zoomIn(); break; case R.id.zoomout: mapView.getController().zoomOut(); break; case R.id.sat: mapView.setSatellite(true); break; case R.id.street: mapView.setStreetView(true); break; case R.id.traffic: mapView.setTraffic(true); break; case R.id.normal: mapView.setSatellite(false); mapView.setStreetView(false); mapView.setTraffic(false); break; } } @Override protected boolean isLocationDisplayed() { return false; } @Override protected boolean isRouteDisplayed() { return false; } manifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="menu.dot" android:versionCode="1" ndroid:versionName="1.0"> <application android:label="@string/app_name" android:icon="@drawable/icon"> <uses-library android:name="com.google.android.maps" /> <activity android:name="MainActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".About"> android:label="@string/about_title" android:theme="@android:style/Theme.Dialog" > </activity> <activity android:name=".Exit"> andorid:label="@string/exit_title"> </activity> <activity android:name=".Options"> </activity> <activity android:name=".Start"> </activity> <activity android:name=".Create"> </activity> <activity android:name=".Where"> </activity> <activity android:name=".Proceed"> </activity> <activity android:name=".Finish"> </activity> <activity android:name=".Login"> </activity> <activity android:name=".OK"> </activity> <activity android:name=".UserPanel"> </activity> <activity android:name=".Managero"> </activity> <activity android:name=".Edition"> </activity> <activity android:name=".Done"> </activity> <activity android:name=".Delete"> </activity> <activity android:name=".MapMapa"> </activity> </application> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-permission android:name="android.permission.INTERNET"/> <uses-sdk android:minSdkVersion="3" /> </manifest>

    Read the article

  • Get the current location of the Gps? Showing the default one

    - by Gagandeep
    Need help Urgent!!!!! Did changes with help but still unsuccessful... I have to request location updates, but I am unsuccessful in implementing that... i modified the code but need help so that i can see the current location. PLEASE look through my code and help please.. I am learning this and new to this concept and android.. any help would be appreciated here is my code: package com.GoogleMaps; 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 android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Point; import android.graphics.drawable.Drawable; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.widget.Toast; public class MapsActivity extends MapActivity { /** Called when the activity is first created. */ private MapView mapView; private LocationManager lm; private LocationListener ll; private MapController mc; GeoPoint p = null; Drawable defaultMarker = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mapView = (MapView)findViewById(R.id.mapview); //show zoom in/out buttons mapView.setBuiltInZoomControls(true); //Standard view of the map(map/sat) mapView.setSatellite(false); // get zoom tool mapView.setBuiltInZoomControls(true); //get controller of the map for zooming in/out mc = mapView.getController(); // Zoom Level mc.setZoom(18); lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); ll = new MyLocationListener(); lm.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, ll); //Get the current location in start-up lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); ll = new MyLocationListener(); lm.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, ll); //Get the current location in start-up if (lm.getLastKnownLocation(LocationManager.GPS_PROVIDER) != null){ GeoPoint p = new GeoPoint( (int)(lm.getLastKnownLocation(LocationManager.GPS_PROVIDER).getLatitude()*1000000), (int)(lm.getLastKnownLocation(LocationManager.GPS_PROVIDER).getLongitude()*1000000)); mc.animateTo(p); } MyLocationOverlay myLocationOverlay = new MyLocationOverlay(); List<Overlay> list = mapView.getOverlays(); list.add(myLocationOverlay); } protected class MyLocationOverlay extends com.google.android.maps.Overlay { @Override public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) { Paint paint = new Paint(); super.draw(canvas, mapView, shadow); GeoPoint p = null; // Converts lat/lng-Point to OUR coordinates on the screen. Point myScreenCoords = new Point(); mapView.getProjection().toPixels(p, myScreenCoords); paint.setStrokeWidth(1); paint.setARGB(255, 255, 255, 255); paint.setStyle(Paint.Style.STROKE); Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); canvas.drawBitmap(bmp, myScreenCoords.x, myScreenCoords.y, paint); canvas.drawText("I am here...", myScreenCoords.x, myScreenCoords.y, paint); return true; } } private class MyLocationListener implements LocationListener{ public void onLocationChanged(Location argLocation) { // TODO Auto-generated method stub p = new GeoPoint((int)(argLocation.getLatitude()*1000000), (int)(argLocation.getLongitude()*1000000)); Toast.makeText(getBaseContext(), "New location latitude [" +argLocation.getLatitude() + "] longitude [" + argLocation.getLongitude()+"]", Toast.LENGTH_SHORT).show(); mc.animateTo(p); mapView.invalidate(); // call this so UI of map was updated } public void onProviderDisabled(String provider) { // TODO Auto-generated method stub } public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } public void onStatusChanged(String provider, int status, Bundle extras) { // TODO Auto-generated method stub } } protected boolean isRouteDisplayed() { return false; } } catlog: 11-29 17:40:42.699: D/dalvikvm(371): GC_FOR_MALLOC freed 6074 objects / 369952 bytes in 74ms 11-29 17:40:42.970: I/MapActivity(371): Handling network change notification:CONNECTED 11-29 17:40:42.980: E/MapActivity(371): Couldn't get connection factory client 11-29 17:40:43.190: D/AndroidRuntime(371): Shutting down VM 11-29 17:40:43.190: W/dalvikvm(371): threadid=1: thread exiting with uncaught exception (group=0x4001d800) 11-29 17:40:43.280: E/AndroidRuntime(371): FATAL EXCEPTION: main 11-29 17:40:43.280: E/AndroidRuntime(371): java.lang.NullPointerException 11-29 17:40:43.280: E/AndroidRuntime(371): at com.google.android.maps.PixelConverter.toPixels(PixelConverter.java:71) 11-29 17:40:43.280: E/AndroidRuntime(371): at com.google.android.maps.PixelConverter.toPixels(PixelConverter.java:61) 11-29 17:40:43.280: E/AndroidRuntime(371): at com.GoogleMaps.MapsActivity$MyLocationOverlay.draw(MapsActivity.java:106) 11-29 17:40:43.280: E/AndroidRuntime(371): at com.google.android.maps.OverlayBundle.draw(OverlayBundle.java:42) 11-29 17:40:43.280: E/AndroidRuntime(371): at com.google.android.maps.MapView.onDraw(MapView.java:494) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.view.View.draw(View.java:6740) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.view.ViewGroup.drawChild(ViewGroup.java:1640) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.view.ViewGroup.drawChild(ViewGroup.java:1638) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.view.View.draw(View.java:6743) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.widget.FrameLayout.draw(FrameLayout.java:352) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.view.ViewGroup.drawChild(ViewGroup.java:1640) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.view.ViewGroup.drawChild(ViewGroup.java:1638) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.view.View.draw(View.java:6743) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.widget.FrameLayout.draw(FrameLayout.java:352) 11-29 17:40:43.280: E/AndroidRuntime(371): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1842) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.view.ViewRoot.draw(ViewRoot.java:1407) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.view.ViewRoot.performTraversals(ViewRoot.java:1163) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.view.ViewRoot.handleMessage(ViewRoot.java:1727) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.os.Handler.dispatchMessage(Handler.java:99) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.os.Looper.loop(Looper.java:123) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.app.ActivityThread.main(ActivityThread.java:4627) 11-29 17:40:43.280: E/AndroidRuntime(371): at java.lang.reflect.Method.invokeNative(Native Method) 11-29 17:40:43.280: E/AndroidRuntime(371): at java.lang.reflect.Method.invoke(Method.java:521) 11-29 17:40:43.280: E/AndroidRuntime(371): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 11-29 17:40:43.280: E/AndroidRuntime(371): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 11-29 17:40:43.280: E/AndroidRuntime(371): at dalvik.system.NativeStart.main(Native Method) 11-29 17:40:45.779: D/dalvikvm(371): GC_FOR_MALLOC freed 5970 objects / 506624 bytes in 1179ms 11-29 17:40:45.779: I/dalvikvm-heap(371): Grow heap (frag case) to 3.147MB for 17858-byte allocation 11-29 17:40:45.870: D/dalvikvm(371): GC_FOR_MALLOC freed 56 objects / 2304 bytes in 92ms 11-29 17:40:45.960: D/dalvikvm(371): GC_EXPLICIT freed 3459 objects / 196432 bytes in 74ms 11-29 17:40:48.310: D/dalvikvm(371): GC_EXPLICIT freed 116 objects / 41448 bytes in 68ms 11-29 17:40:49.540: I/Process(371): Sending signal. PID: 371 SIG: 9

    Read the article

  • Google Map key in Android?

    - by Amandeep singh
    I am developing an android app in which i have to show map view i have done it once in a previous app but the key i used in the previous is not working int his app . It is just showing a pin in the application with blank screen. Do i have to use a different Map key for each project , If not Kindly help me how can i use my previous Key in this. and also I tried generating a new key but gave the the same key back . Here is the code i used public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.map); btn=(Button)findViewById(R.id.mapbtn); str1=getIntent().getStringExtra("LATITUDE"); str2=getIntent().getStringExtra("LONGITUDE"); mapView = (MapView)findViewById(R.id.mapView1); //View zoomView = mapView.getZoomControls(); mapView.setBuiltInZoomControls(true); //mapView.setSatellite(true); mc = mapView.getController(); btn.setOnClickListener(this); MapOverlay mapOverlay = new MapOverlay(); List<Overlay> listOfOverlays = mapView.getOverlays(); listOfOverlays.clear(); listOfOverlays.add(mapOverlay); String coordinates[] = {str1, str2}; double lat = Double.parseDouble(coordinates[0]); double lng = Double.parseDouble(coordinates[1]); p = new GeoPoint( (int) (lat * 1E6), (int) (lng * 1E6)); mc.animateTo(p); mc.setZoom(17); mapView.invalidate(); //mp.equals(o); } @Override protected boolean isRouteDisplayed() { // TODO Auto-generated method stub return false; } class MapOverlay extends com.google.android.maps.Overlay { @Override public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) { super.draw(canvas, mapView, shadow); Paint mPaint = new Paint(); mPaint.setDither(true); mPaint.setColor(Color.RED); mPaint.setStyle(Paint.Style.FILL_AND_STROKE); mPaint.setStrokeJoin(Paint.Join.ROUND); mPaint.setStrokeCap(Paint.Cap.ROUND); mPaint.setStrokeWidth(2); //---translate the GeoPoint to screen pixels--- Point screenPts = new Point(); mapView.getProjection().toPixels(p, screenPts); //---add the marker--- Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.pin); canvas.drawBitmap(bmp, screenPts.x, screenPts.y-50, null); return true; } Thanks....

    Read the article

  • How to overlay GLSurfaceView over a MapView in Android?

    - by Rajapandian
    Hi, I want to create a simple Map based application in android ,where i can display my current position.Instead of overlaying a simple Image on the MapView to represent the position, i want to overlay the GLSurfaceView on the MapView. But i don't know how to achieve this. Is there any way to do that?. Please anybody knows the solution help me.

    Read the article

  • how do i add images from drable folder instead of url in this code

    - by hayya anam
    i used the following URL https://github.com/jgilfelt/android-mapviewballoons source in my application is show image by using url how do i give images form my own drawable folder?? i found this mapview url which show images inbaloon but is show images by url i wanna show myown iamges how i do? howi give my own images from my folder public class CustomMap extends MapActivity { MapView mapView; List<Overlay> mapOverlays; Drawable drawable; Drawable drawable2; CustomItemizedOverlay<CustomOverlayItem> itemizedOverlay; CustomItemizedOverlay<CustomOverlayItem> itemizedOverlay2; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mapView = (MapView) findViewById(R.id.mapview); mapView.setBuiltInZoomControls(true); mapOverlays = mapView.getOverlays(); // first overlay drawable = getResources().getDrawable(R.drawable.marker); itemizedOverlay = new CustomItemizedOverlay<CustomOverlayItem>(drawable, mapView); GeoPoint point = new GeoPoint((int)(51.5174723*1E6),(int)(-0.0899537*1E6)); CustomOverlayItem overlayItem = new CustomOverlayItem(point, "Tomorrow Never Dies (1997)", "(M gives Bond his mission in Daimler car)", "http://ia.media-imdb.com/images /M/MV5BMTM1MTk2ODQxNV5BMl5BanBnXkFtZTcwOTY5MDg0NA@@._V1._SX40_CR0,0,40,54_.jpg"); itemizedOverlay.addOverlay(overlayItem); GeoPoint point2 = new GeoPoint((int)(51.515259*1E6),(int)(-0.086623*1E6)); CustomOverlayItem overlayItem2 = new CustomOverlayItem(point2, "GoldenEye (1995)", "(Interiors Russian defence ministry council chambers in St Petersburg)", "http://ia.media-imdb.com/images M/MV5BMzk2OTg 4MTk1NF5BMl5BanBnXkFtZTcwNjExNTgzNA@@._V1._SX40_CR0,0,40,54_.jpg"); itemizedOverlay.addOverlay(overlayItem2); mapOverlays.add(itemizedOverlay); // second overlay drawable2 = getResources().getDrawable(R.drawable.marker2); itemizedOverlay2 = new CustomItemizedOverlay<CustomOverlayItem> (drawable2, mapView); GeoPoint point3 = new GeoPoint((int)(51.513329*1E6),(int)(-0.08896*1E6)); CustomOverlayItem overlayItem3 = new CustomOverlayItem(point3, "Sliding Doors (1998)", "(interiors)", null); itemizedOverlay2.addOverlay(overlayItem3); GeoPoint point4 = new GeoPoint((int)(51.51738*1E6),(int)(-0.08186*1E6)); CustomOverlayItem overlayItem4 = new CustomOverlayItem(point4, "Mission: Impossible (1996)", "(Ethan & Jim cafe meeting)", "http://ia.media-imdb.com/images /M/MV5BMjAyNjk5Njk0MV 5BMl5BanBnXkFtZTcwOTA4MjIyMQ@@._V1._SX40_CR0,0,40,54_.jpg"); itemizedOverlay2.addOverlay(overlayItem4); mapOverlays.add(itemizedOverlay2); final MapController mc = mapView.getController(); mc.animateTo(point2); mc.setZoom(16); } @Override protected boolean isRouteDisplayed() { return false; } }

    Read the article

  • Where should I put zoomIn in my MapActivity?

    - by Johny
    I'm writing an Android app, and I'd like to zoomIn as soon as the map has been loaded. I get the following error: java.lang.IllegalArgumentException: width and height must be > 0 This MapActivity - width and height must be > 0 question suggests the problem is the zoomIn() method is in the onCreate() method. But I get same error when I put it in the onResume() method. I've been searching for hours and I can't find anything about it at http://developer.android.com or anywhere else... Also I can't find a way to get the time point the map has been loaded. A "MapLoadedListener" or something like that... EDIT Here is my code: public class AMap extends MapActivity{ private final String LOG_TAG = this.getClass().getSimpleName(); private Context mContext; private Chronometer timer; private TextView tvCountdown; private RelativeLayout rl; private MapView mapView; private MapController mapController; private List<Overlay> mapOverlays; private PlayersOverlay playersOverlay; private Drawable drawable; private Builder endDialog; private ContextThemeWrapper ctw; private Handler mHandler = new Handler(); private Player player = new Player(); private StartTask startTask; private EndTask endTask; private MyDBAdapter mdba; private Cursor playersCursor; private UpdateBroadcastReceiver r; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.map_view); mContext = AMap.this; // set map mapView = (MapView) findViewById(R.id.mapview); mapView.setBuiltInZoomControls(true); mapView.setFocusable(true); // find the relative layout rl = (RelativeLayout) findViewById(R.id.rl); // set the chronometer timer = (Chronometer) findViewById(R.id.tv_timer); timer.setBackgroundColor(Color.DKGRAY); // set the countdown textview tvCountdown = (TextView) findViewById(R.id.tv_countdown); // Open DB connection and get players Cursor mdba = new MyDBAdapter(mContext); mdba.open(); playersCursor = mdba.getGame(); // Get this player's id and location Intent starter = this.getIntent(); player.setId(starter.getIntExtra("id", 0)); player.setLatitude(starter.getDoubleExtra("lat", 0)); player.setLongitude(starter.getDoubleExtra("lon", 0)); // Set this player's location as map's center GeoPoint geoPoint = new GeoPoint((int) (player.getLatitude()*1E6), (int) (player.getLongitude()*1E6)); mapController = mapView.getController(); mapController.setCenter(geoPoint); mapController.setZoom(15); Log.d(LOG_TAG, "My playersCursor has "+playersCursor.getCount()+" rows"); // drawable is needed but not used drawable = this.getResources().getDrawable(R.drawable.ic_launcher); // set PlayersOverlay (locations and statuses) playersOverlay = new PlayersOverlay(player.getId(), playersCursor, drawable, this); mapOverlays = mapView.getOverlays(); mapOverlays.add(playersOverlay); mHandler.postDelayed(mUpdateTimeTask, 100); } private Runnable mUpdateTimeTask = new Runnable() { public void run() { int h = mapView.getLayoutParams().height; int w = mapView.getLayoutParams().width; Log.d(LOG_TAG, "w = "+w+" , h = "+h); mHandler.postAtTime(this, System.currentTimeMillis() + 1000); } }; @Override public void onAttachedToWindow(){ Log.d(LOG_TAG, "Attached to Window"); int h = mapView.getLayoutParams().height; int w = mapView.getLayoutParams().width; Log.d(LOG_TAG, " Attached to window: w = "+w+" , h = "+h); //mapController.zoomInFixing(screenPoint.x, screenPoint.y); } public void onWindowFocusChanged(boolean hasFocus){ Log.d(LOG_TAG, "Focus changed to: "+hasFocus); int h = mapView.getLayoutParams().height; int w = mapView.getLayoutParams().width; Log.d(LOG_TAG, " Window focus changed: w = "+w+" , h = "+h); //mapController.zoomInFixing(screenPoint.x, screenPoint.y); } @Override protected void onStart(){ super.onStart(); // Create and register the broadcast receiver for messages from service IntentFilter filter = new IntentFilter(AppConstants.iGAME_UPDATE); r = new UpdateBroadcastReceiver(); registerReceiver(r, filter); // Create the dialog for end of game ctw = new ContextThemeWrapper(mContext, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen); endDialog = new AlertDialog.Builder(ctw); endDialog.setMessage("End of Game"); endDialog.setCancelable(false); endDialog.setNeutralButton("OK", new OnClickListener(){ @Override public void onClick(DialogInterface dialog, int which) { Intent highScores = new Intent(AMap.this, HighScores.class); startActivity(highScores); playersCursor.close(); finish(); } }); } @Override protected void onStop() { if(!playersCursor.isClosed()) playersCursor.close(); unregisterReceiver(r); mdba.close(); super.onStop(); } @Override protected boolean isRouteDisplayed() { return false; } // Receives signal from NetworkService that DB has been updated public class UpdateBroadcastReceiver extends BroadcastReceiver { boolean startSignal, update, endSignal; @Override public void onReceive(Context context, Intent intent) { endSignal = intent.getBooleanExtra("endSignal", false); if(endSignal){ Log.d(LOG_TAG, "Game Update BroadcastReceiver received End Signal"); endTask = new EndTask(); endTask.execute(); return; } update = intent.getBooleanExtra("update", false); if(update){ Log.d(LOG_TAG, "Game Update BroadcastReceiver received game update"); playersCursor.requery(); mapView.invalidate(); return; } startSignal = intent.getBooleanExtra("startSignal", false); if(startSignal){ Log.d(LOG_TAG, "Game Update BroadcastReceiver received Start Signal"); startTask = new StartTask(); startTask.execute(); return; } } } class StartTask extends AsyncTask<Void,Integer,Void>{ private final ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100); private final long DELAY = 1200; @Override protected Void doInBackground(Void... params) { int i = 3; while(i>=0){ publishProgress(i); try { Thread.sleep(DELAY); } catch (InterruptedException e) { e.printStackTrace(); } i--; } return null; } @Override protected void onProgressUpdate(Integer... progress){ tg.startTone(ToneGenerator.TONE_PROP_PROMPT); tvCountdown.setText(""+progress[0]); } @Override protected void onPostExecute(Void result) { rl.removeView(tvCountdown); timer.setBase(SystemClock.elapsedRealtime()); timer.start(); //enable screen touches playersOverlay.setGameStarted(true); } } class EndTask extends AsyncTask<Void,Void,Void>{ @Override protected void onPreExecute(){ //disable screen touches playersOverlay.setEndOfGame(true); timer.stop(); } @Override protected Void doInBackground(Void... params) { return null; } @Override protected void onPostExecute(Void result) { try{ endDialog.show(); }catch(Exception e){ Toast.makeText(mContext, "End of game", Toast.LENGTH_LONG); Intent highScores = new Intent(AMap.this, HighScores.class); startActivity(highScores); playersCursor.close(); finish(); } mHandler.removeCallbacks(mUpdateTimeTask); } } }

    Read the article

  • map is not showing correct location in my blackberry applications

    - by Ali
    I am calling blackberry map by converting the real coordinates as you can see public static void showMap(String latitude,String longatude){ try{ int specailLatitude=(int)(Double.parseDouble(latitude))*100000; int specailLongatude=(int)(Double.parseDouble(longatude))*100000; MapView mapView=new MapView(); mapView.setLatitude(specailLatitude); mapView.setLongitude(specailLongatude); mapView.setZoom(07); MapsArguments arg=new MapsArguments(mapView); Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, arg); }catch(Exception e){ CustomUtility.showToast("Map is not available "+e.getMessage()); } }// end of the showMap but problem is this its now showing correct location , it always shows same location in UAE , please help that i am converting correctly ?

    Read the article

  • How to add the coding for displaying the address when a particular set of latitude and longitude is

    - by KKC
    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 android.os.Bundle; import android.view.KeyEvent; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Spinner; import android.widget.AdapterView.OnItemSelectedListener; public class PopularAttractions extends MapActivity { private String[ ][ ] locations = { {"Singapore Zoological Garden","1.40502,103.793449"}, {"Singapore Night Safari","1.4037,103.789467"}, {"Jurong BirdPark","1.32005,103.707153"}, {"Jurong Reptile Park","1.321177,103.708486"}, {"Singapore Botanic Garden","1.31471,103.815689"}, {"Sungei Buloh Wetland Reserver","1.445144,103.729595"}, {"Escape Theme Park","1.38104,103.936928"}, {"Snow City","1.32823,103.74263"}, {"Super Ice World","1.300422,103.875348"}, {"Chinatown Heritage Center","1.2836,103.84425"}, {"Singapore Science Center","1.3249,103.740578"}, {"Red Dot Design Museum","1.277762,103.846225"}, {"G-Max Reverse Bungy","1.2906,103.845322"}, {"NEWater Visitor Center","1.33105,103.955311"} }; private Spinner spinnerView; private MapView mapView; private MapController mc; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); spinnerView = (Spinner) this.findViewById(R.id.spinner1); mapView = (MapView) findViewById(R.id.mapview1); mc = mapView.getController(); ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_dropdown_item); //--add the various locations--- for(int i = 0; i < locations.length; i++) adapter.add(locations[i][0]); adapter.setDropDownViewResource( android.R.layout.simple_spinner_dropdown_item); spinnerView.setAdapter(adapter); spinnerView.setOnItemSelectedListener(selectListener); gotoSelected(); } //---when user selects an item--- private OnItemSelectedListener selectListener = new OnItemSelectedListener() { //---these are two methods you need to implement--- public void onItemSelected( AdapterView<?>parent, View v, int position, long id) { gotoSelected(); } public void onNothingSelected(AdapterView<?> arg0) {} }; //---when an item has been selected--- public void gotoSelected() { int index = spinnerView.getSelectedItemPosition(); String[] coordinates = locations[index][1].split(","); double lat = Double.parseDouble(coordinates[0]); double lng = Double.parseDouble(coordinates[1]); GeoPoint location = new GeoPoint ( (int)(lat * 1E6), (int)(lng * 1E6)); mc.animateTo(location); mc.setZoom(16); if (mapView.isSatellite()) mapView.setSatellite(false); else mapView.setStreetView(true); mapView.invalidate(); } public boolean onKeyDown(int keyCode, KeyEvent event) { MapController mc = mapView.getController(); switch (keyCode) { case KeyEvent.KEYCODE_3: mc.zoomIn(); break; case KeyEvent.KEYCODE_1: mc.zoomOut(); break; } return super.onKeyDown(keyCode, event); } @Override protected boolean isRouteDisplayed(){ //TODO Auto-generated method sub return false; } }

    Read the article

  • Marking Current Location on Map, Android

    - by deewangan
    Hi every one, i followed some tutorials to create an application that shows the current position of the user on the map with a marking. but for some reasons i can't get to work the marking part? the other parts works well, but whenever i add the marking code the application crashes. i hope someone could help me.here is the code: public class LocationActivity extends MapActivity { /** Called when the activity is first created. */ private MapView mapView; private LocationManager lm; private LocationListener ll; private MapController mc; GeoPoint p = null; Drawable defaultMarker = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mapView = (MapView)findViewById(R.id.mapView); //show zoom in/out buttons mapView.setBuiltInZoomControls(true); //Standard view of the map(map/sat) mapView.setSatellite(false); //get controller of the map for zooming in/out mc = mapView.getController(); // Zoom Level mc.setZoom(18); MyLocationOverlay myLocationOverlay = new MyLocationOverlay(); List<Overlay> list = mapView.getOverlays(); list.add(myLocationOverlay); lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); ll = new MyLocationListener(); lm.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, ll); //Get the current location in start-up GeoPoint initGeoPoint = new GeoPoint( (int)(lm.getLastKnownLocation( LocationManager.GPS_PROVIDER) .getLatitude()*1000000), (int)(lm.getLastKnownLocation( LocationManager.GPS_PROVIDER) .getLongitude()*1000000)); mc.animateTo(initGeoPoint); } protected class MyLocationOverlay extends com.google.android.maps.Overlay { @Override public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) { Paint paint = new Paint(); super.draw(canvas, mapView, shadow); // Converts lat/lng-Point to OUR coordinates on the screen. Point myScreenCoords = new Point(); mapView.getProjection().toPixels(p, myScreenCoords); paint.setStrokeWidth(1); paint.setARGB(255, 255, 255, 255); paint.setStyle(Paint.Style.STROKE); Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.push); canvas.drawBitmap(bmp, myScreenCoords.x, myScreenCoords.y, paint); canvas.drawText("I am here...", myScreenCoords.x, myScreenCoords.y, paint); return true; } } private class MyLocationListener implements LocationListener{ public void onLocationChanged(Location argLocation) { // TODO Auto-generated method stub GeoPoint myGeoPoint = new GeoPoint( (int)(argLocation.getLatitude()*1000000), (int)(argLocation.getLongitude()*1000000)); /* * it will show a message on * location change Toast.makeText(getBaseContext(), "New location latitude [" +argLocation.getLatitude() + "] longitude [" + argLocation.getLongitude()+"]", Toast.LENGTH_SHORT).show(); */ mc.animateTo(myGeoPoint); } public void onProviderDisabled(String provider) { // TODO Auto-generated method stub } public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } public void onStatusChanged(String provider, int status, Bundle extras) { // TODO Auto-generated method stub } } protected boolean isRouteDisplayed() { return false; } } here is the logcat: 01-19 05:31:43.011: DEBUG/AndroidRuntime(759): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<< 01-19 05:31:43.011: DEBUG/AndroidRuntime(759): CheckJNI is ON 01-19 05:31:43.411: DEBUG/AndroidRuntime(759): --- registering native functions --- 01-19 05:31:43.431: INFO/jdwp(759): received file descriptor 19 from ADB 01-19 05:31:43.431: INFO/jdwp(759): Ignoring second debugger -- accepting and dropping 01-19 05:31:44.531: INFO/ActivityManager(583): Starting activity: Intent { flg=0x10000000 cmp=pro.googlemapp/.LocationActivity } 01-19 05:31:44.641: DEBUG/AndroidRuntime(759): Shutting down VM 01-19 05:31:44.641: DEBUG/dalvikvm(759): DestroyJavaVM waiting for non-daemon threads to exit 01-19 05:31:44.641: DEBUG/dalvikvm(759): DestroyJavaVM shutting VM down 01-19 05:31:44.641: DEBUG/dalvikvm(759): HeapWorker thread shutting down 01-19 05:31:44.651: DEBUG/dalvikvm(759): HeapWorker thread has shut down 01-19 05:31:44.651: DEBUG/jdwp(759): JDWP shutting down net... 01-19 05:31:44.651: DEBUG/jdwp(759): +++ peer disconnected 01-19 05:31:44.651: INFO/dalvikvm(759): Debugger has detached; object registry had 1 entries 01-19 05:31:44.661: DEBUG/dalvikvm(759): VM cleaning up 01-19 05:31:44.681: INFO/ActivityManager(583): Start proc pro.googlemapp for activity pro.googlemapp/.LocationActivity: pid=770 uid=10025 gids={3003} 01-19 05:31:44.761: DEBUG/dalvikvm(759): LinearAlloc 0x0 used 676436 of 4194304 (16%) 01-19 05:31:44.801: INFO/jdwp(770): received file descriptor 20 from ADB 01-19 05:31:44.822: INFO/dalvikvm(770): ignoring registerObject request in thread=3 01-19 05:31:44.851: INFO/jdwp(770): Ignoring second debugger -- accepting and dropping 01-19 05:31:44.851: ERROR/jdwp(770): Failed writing handshake bytes: Broken pipe (-1 of 14) 01-19 05:31:44.851: INFO/dalvikvm(770): Debugger has detached; object registry had 0 entries 01-19 05:31:45.320: ERROR/ActivityThread(770): Failed to find provider info for com.google.settings 01-19 05:31:45.320: ERROR/ActivityThread(770): Failed to find provider info for com.google.settings 01-19 05:31:45.340: ERROR/ActivityThread(770): Failed to find provider info for com.google.settings 01-19 05:31:45.781: DEBUG/LocationManager(770): Constructor: service = android.location.ILocationManager$Stub$Proxy@4379d9f0 01-19 05:31:45.791: WARN/GpsLocationProvider(583): Duplicate add listener for uid 10025 01-19 05:31:45.791: DEBUG/GpsLocationProvider(583): setMinTime 0 01-19 05:31:45.791: DEBUG/GpsLocationProvider(583): startNavigating 01-19 05:31:45.831: INFO/jdwp(770): received file descriptor 27 from ADB 01-19 05:31:46.001: INFO/MapActivity(770): Handling network change notification:CONNECTED 01-19 05:31:46.001: ERROR/MapActivity(770): Couldn't get connection factory client 01-19 05:31:46.451: DEBUG/dalvikvm(770): GC freed 4539 objects / 298952 bytes in 118ms 01-19 05:31:46.470: DEBUG/AndroidRuntime(770): Shutting down VM 01-19 05:31:46.470: WARN/dalvikvm(770): threadid=3: thread exiting with uncaught exception (group=0x4001aa28) 01-19 05:31:46.481: ERROR/AndroidRuntime(770): Uncaught handler: thread main exiting due to uncaught exception 01-19 05:31:46.541: ERROR/AndroidRuntime(770): java.lang.NullPointerException 01-19 05:31:46.541: ERROR/AndroidRuntime(770): at com.google.android.maps.PixelConverter.toPixels(PixelConverter.java:58) 01-19 05:31:46.541: ERROR/AndroidRuntime(770): at com.google.android.maps.PixelConverter.toPixels(PixelConverter.java:48) 01-19 05:31:46.541: ERROR/AndroidRuntime(770): at pro.googlemapp.LocationActivity$MyLocationOverlay.draw(LocationActivity.java:101) 01-19 05:31:46.541: ERROR/AndroidRuntime(770): at com.google.android.maps.OverlayBundle.draw(OverlayBundle.java:42) 01-19 05:31:46.541: ERROR/AndroidRuntime(770): at com.google.android.maps.MapView.onDraw(MapView.java:476) 01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.view.View.draw(View.java:6274) 01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.view.ViewGroup.drawChild(ViewGroup.java:1526) 01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256) 01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.view.ViewGroup.drawChild(ViewGroup.java:1524) 01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256) 01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.view.View.draw(View.java:6277) 01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.widget.FrameLayout.draw(FrameLayout.java:352) 01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.view.ViewGroup.drawChild(ViewGroup.java:1526) 01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256) 01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.view.ViewGroup.drawChild(ViewGroup.java:1524) 01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256) 01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.view.View.draw(View.java:6277) 01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.widget.FrameLayout.draw(FrameLayout.java:352) 01-19 05:31:46.541: ERROR/AndroidRuntime(770): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1883) 01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.view.ViewRoot.draw(ViewRoot.java:1332) 01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.view.ViewRoot.performTraversals(ViewRoot.java:1097) 01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.view.ViewRoot.handleMessage(ViewRoot.java:1613) 01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.os.Handler.dispatchMessage(Handler.java:99) 01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.os.Looper.loop(Looper.java:123) 01-19 05:31:46.541: ERROR/AndroidRuntime(770): at android.app.ActivityThread.main(ActivityThread.java:4203) 01-19 05:31:46.541: ERROR/AndroidRuntime(770): at java.lang.reflect.Method.invokeNative(Native Method) 01-19 05:31:46.541: ERROR/AndroidRuntime(770): at java.lang.reflect.Method.invoke(Method.java:521) 01-19 05:31:46.541: ERROR/AndroidRuntime(770): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791) 01-19 05:31:46.541: ERROR/AndroidRuntime(770): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549) 01-19 05:31:46.541: ERROR/AndroidRuntime(770): at dalvik.system.NativeStart.main(Native Method) 01-19 05:31:46.551: INFO/Process(583): Sending signal. PID: 770 SIG: 3 01-19 05:31:46.581: INFO/dalvikvm(770): threadid=7: reacting to signal 3 01-19 05:31:46.661: INFO/dalvikvm(770): Wrote stack trace to '/data/anr/traces.txt' 01-19 05:31:46.871: INFO/ARMAssembler(583): generated scanline__00000077:03515104_00000000_00000000 [ 27 ipp] (41 ins) at [0x2c69c8:0x2c6a6c] in 973448 ns 01-19 05:31:46.911: INFO/ARMAssembler(583): generated scanline__00000077:03515104_00001001_00000000 [ 64 ipp] (84 ins) at [0x2c6a70:0x2c6bc0] in 1985378 ns 01-19 05:31:49.881: INFO/Process(770): Sending signal. PID: 770 SIG: 9 01-19 05:31:49.931: INFO/ActivityManager(583): Process pro.googlemapp (pid 770) has died. 01-19 05:31:49.941: WARN/GpsLocationProvider(583): Unneeded remove listener for uid 1000 01-19 05:31:49.941: DEBUG/GpsLocationProvider(583): stopNavigating 01-19 05:31:49.951: INFO/WindowManager(583): WIN DEATH: Window{438891c0 pro.googlemapp/pro.googlemapp.LocationActivity paused=false} 01-19 05:31:50.111: WARN/UsageStats(583): Unexpected resume of com.android.launcher while already resumed in pro.googlemapp 01-19 05:31:50.200: WARN/InputManagerService(583): Got RemoteException sending setActive(false) notification to pid 770 uid 10025

    Read the article

  • Android Google map balloon over overlayitem

    - by Faisal khan
    I am using google map, displaying overlayitems on the google map. To create balloon effect, i am using customize view and using geopoints with MapView.LayoutParams to display it at particular location. overlayitem's icon and baloon both having same geopoint thats why they both are overriding eatch other. I want to display baloon over the overlayitem icon look like it should point to the icon. Follwing is my code MapView.LayoutParams mapParams = new MapView.LayoutParams(MapView.LayoutParams.WRAP_CONTENT, MapView.LayoutParams.WRAP_CONTENT, mapEvent.getGeoPoint(), MapView.LayoutParams.BOTTOM_CENTER); I want to display baloon like following please tell me should i decrease lat long to make it top ? or should i change the layout param.Bottom or what i tried different variation not working like following

    Read the article

  • How can I pass latitude and longitude values from UIViewController to MKMapView?

    - by jerincbus
    I have a detail view that includes three UIButtons, each of which pushes a different view on to the stack. One of the buttons is connected to a MKMapView. When that button is pushed I need to send the latitude and longitude variables from the detail view to the map view. I'm trying to add the string declaration in the IBAction: - (IBAction)goToMapView { MapViewController *mapController = [[MapViewController alloc] initWithNibName:@"MapViewController" bundle:nil]; mapController.mapAddress = self.address; mapController.mapTitle = self.Title; mapController.mapLat = self.lat; mapController.mapLng = self.lng; //Push the new view on the stack [[self navigationController] pushViewController:mapController animated:YES]; [mapController release]; //mapController = nil; } And on my MapViewController.h file I have: #import <UIKit/UIKit.h> #import <MapKit/MapKit.h> #import "DetailViewController.h" #import "CourseAnnotation.h" @class CourseAnnotation; @interface MapViewController : UIViewController <MKMapViewDelegate> { IBOutlet MKMapView *mapView; NSString *mapAddress; NSString *mapTitle; NSNumber *mapLat; NSNumber *mapLng; } @property (nonatomic, retain) IBOutlet MKMapView *mapView; @property (nonatomic, retain) NSString *mapAddress; @property (nonatomic, retain) NSString *mapTitle; @property (nonatomic, retain) NSNumber *mapLat; @property (nonatomic, retain) NSNumber *mapLng; @end And on the pertinent parts of the MapViewController.m file I have: @synthesize mapView, mapAddress, mapTitle, mapLat, mapLng; - (void)viewDidLoad { [super viewDidLoad]; [mapView setMapType:MKMapTypeStandard]; [mapView setZoomEnabled:YES]; [mapView setScrollEnabled:YES]; MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } }; region.center.latitude = mapLat; //40.105085; region.center.longitude = mapLng; //-83.005237; region.span.longitudeDelta = 0.01f; region.span.latitudeDelta = 0.01f; [mapView setRegion:region animated:YES]; [mapView setDelegate:self]; CourseAnnotation *ann = [[CourseAnnotation alloc] init]; ann.title = mapTitle; ann.subtitle = mapAddress; ann.coordinate = region.center; [mapView addAnnotation:ann]; } But I get this when I try to build: 'error: incompatible types in assignment' for both lat and lng variables. So my questions are am I going about passing the variables from one view to another the right way? And does the MKMapView accept latitude and longitude as a string or a number?

    Read the article

  • Adding marker to the retrieved location

    - by Rahul Varma
    I have displayed the map in my app by using the following code. I have retrieved info from the database and displayed the map. Now i want to add marker to the retrieved location... googleMao.java public class googleMap extends MapActivity{ private MapView mapView; private MapController mc; GeoPoint p; long s; Cursor cur; SQLiteDatabase db; createSqliteHelper csh; String qurry; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.map); // String qurry=getIntent().getStringExtra("value"); //here is calling the map string qurry s = getIntent().getLongExtra("value",2); map(); mapView = (MapView) findViewById(R.id.mapview1); LinearLayout zoomLayout = (LinearLayout)findViewById(R.id.zoom); View zoomView = mapView.getZoomControls(); zoomLayout.addView(zoomView, new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); //mapView.displayZoomControls(true); mapView.setBuiltInZoomControls(true); mc = mapView.getController(); String coordinates[] = {"1.352566007", "103.78921587"}; double lat = Double.parseDouble(coordinates[0]); double lng = Double.parseDouble(coordinates[1]); Geocoder geoCoder = new Geocoder(this, Locale.getDefault()); try { List<Address> addresses = geoCoder.getFromLocationName(qurry,5); String add = ""; if (addresses.size() > 0) { p = new GeoPoint( (int) (addresses.get(0).getLatitude() * 1E6), (int) (addresses.get(0).getLongitude() * 1E6)); mc.animateTo(p); mapView.invalidate(); mc.setZoom(6); } } catch (IOException e) { e.printStackTrace(); } } @Override protected boolean isRouteDisplayed() { // Required by MapActivity return false; } public void map() { String[] str={"type"}; int[] i={R.id.type}; csh=new createSqliteHelper(this); db=csh.getReadableDatabase(); cur=db.rawQuery("select type from restaurants where _id="+s,null); if(cur.moveToFirst()) { qurry=cur.getString(cur.getColumnIndex("type")); } } }

    Read the article

  • Android map performance with > 800 overlays of KML data

    - by span
    I have some a shape file which I have converted to a KML file that I wish to read coordinates from and then draw paths between the coordinates on a MapView. With the help of this great post: How to draw a path on a map using kml file? I have been able to read the the KML into an ArrayList of "Placemarks". This great blog post then showed how to take a list of GeoPoints and draw a path: http://djsolid.net/blog/android---draw-a-path-array-of-points-in-mapview The example in the above post only draws one path between some points however and since I have many more paths than that I am running into some performance problems. I'm currently adding a new RouteOverlay for each of the separate paths. This results in me having over 800 overlays when they have all been added. This has a performance hit and I would love some input on what I can do to improve it. Here are some options I have considered: Try to add all the points to a List which then can be passed into a class that will extend Overlay. In that new class perhaps it would be possible to add and draw the paths in a single Overlay layer? I'm not sure on how to implement this though since the paths are not always intersecting and they have different start and end points. At the moment I'm adding each path which has several points to it's own list and then I add that to an Overlay. That results in over 700 overlays... Simplify the KML or SHP. Instead of having over 700 different paths, perhaps there is someway to merge them into perhaps 100 paths or less? Since alot of paths are intersected at some point it should be possible to modify the original SHP file so that it merges all intersections. Since I have never worked with these kinds of files before I have not been able to find a way to do this in GQIS. If someone knows how to do this I would love for some input on that. Here is a link to the group of shape files if you are interested: http://danielkvist.net/cprg_bef_cbana_polyline.shp http://danielkvist.net/cprg_bef_cbana_polyline.shx http://danielkvist.net/cprg_bef_cbana_polyline.dbf http://danielkvist.net/cprg_bef_cbana_polyline.prj Anyway, here is the code I'm using to add the Overlays. Many thanks in advance. RoutePathOverlay.java package net.danielkvist; import java.util.List; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Path; import android.graphics.Point; import android.graphics.RectF; import com.google.android.maps.GeoPoint; import com.google.android.maps.MapView; import com.google.android.maps.Overlay; import com.google.android.maps.Projection; public class RoutePathOverlay extends Overlay { private int _pathColor; private final List<GeoPoint> _points; private boolean _drawStartEnd; public RoutePathOverlay(List<GeoPoint> points) { this(points, Color.RED, false); } public RoutePathOverlay(List<GeoPoint> points, int pathColor, boolean drawStartEnd) { _points = points; _pathColor = pathColor; _drawStartEnd = drawStartEnd; } private void drawOval(Canvas canvas, Paint paint, Point point) { Paint ovalPaint = new Paint(paint); ovalPaint.setStyle(Paint.Style.FILL_AND_STROKE); ovalPaint.setStrokeWidth(2); int _radius = 6; RectF oval = new RectF(point.x - _radius, point.y - _radius, point.x + _radius, point.y + _radius); canvas.drawOval(oval, ovalPaint); } public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) { Projection projection = mapView.getProjection(); if (shadow == false && _points != null) { Point startPoint = null, endPoint = null; Path path = new Path(); // We are creating the path for (int i = 0; i < _points.size(); i++) { GeoPoint gPointA = _points.get(i); Point pointA = new Point(); projection.toPixels(gPointA, pointA); if (i == 0) { // This is the start point startPoint = pointA; path.moveTo(pointA.x, pointA.y); } else { if (i == _points.size() - 1)// This is the end point endPoint = pointA; path.lineTo(pointA.x, pointA.y); } } Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(_pathColor); paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(3); paint.setAlpha(90); if (getDrawStartEnd()) { if (startPoint != null) { drawOval(canvas, paint, startPoint); } if (endPoint != null) { drawOval(canvas, paint, endPoint); } } if (!path.isEmpty()) canvas.drawPath(path, paint); } return super.draw(canvas, mapView, shadow, when); } public boolean getDrawStartEnd() { return _drawStartEnd; } public void setDrawStartEnd(boolean markStartEnd) { _drawStartEnd = markStartEnd; } } MyMapActivity package net.danielkvist; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import android.graphics.Color; import android.os.Bundle; import android.util.Log; import com.google.android.maps.GeoPoint; import com.google.android.maps.MapActivity; import com.google.android.maps.MapView; public class MyMapActivity extends MapActivity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); MapView mapView = (MapView) findViewById(R.id.mapview); mapView.setBuiltInZoomControls(true); String url = "http://danielkvist.net/cprg_bef_cbana_polyline_simp1600.kml"; NavigationDataSet set = MapService.getNavigationDataSet(url); drawPath(set, Color.parseColor("#6C8715"), mapView); } /** * Does the actual drawing of the route, based on the geo points provided in * the nav set * * @param navSet * Navigation set bean that holds the route information, incl. * geo pos * @param color * Color in which to draw the lines * @param mMapView01 * Map view to draw onto */ public void drawPath(NavigationDataSet navSet, int color, MapView mMapView01) { ArrayList<GeoPoint> geoPoints = new ArrayList<GeoPoint>(); Collection overlaysToAddAgain = new ArrayList(); for (Iterator iter = mMapView01.getOverlays().iterator(); iter.hasNext();) { Object o = iter.next(); Log.d(BikeApp.APP, "overlay type: " + o.getClass().getName()); if (!RouteOverlay.class.getName().equals(o.getClass().getName())) { overlaysToAddAgain.add(o); } } mMapView01.getOverlays().clear(); mMapView01.getOverlays().addAll(overlaysToAddAgain); int totalNumberOfOverlaysAdded = 0; for(Placemark placemark : navSet.getPlacemarks()) { String path = placemark.getCoordinates(); if (path != null && path.trim().length() > 0) { String[] pairs = path.trim().split(" "); String[] lngLat = pairs[0].split(","); // lngLat[0]=longitude // lngLat[1]=latitude // lngLat[2]=height try { if(lngLat.length > 1 && !lngLat[0].equals("") && !lngLat[1].equals("")) { GeoPoint startGP = new GeoPoint( (int) (Double.parseDouble(lngLat[1]) * 1E6), (int) (Double.parseDouble(lngLat[0]) * 1E6)); GeoPoint gp1; GeoPoint gp2 = startGP; geoPoints = new ArrayList<GeoPoint>(); geoPoints.add(startGP); for (int i = 1; i < pairs.length; i++) { lngLat = pairs[i].split(","); gp1 = gp2; if (lngLat.length >= 2 && gp1.getLatitudeE6() > 0 && gp1.getLongitudeE6() > 0 && gp2.getLatitudeE6() > 0 && gp2.getLongitudeE6() > 0) { // for GeoPoint, first:latitude, second:longitude gp2 = new GeoPoint( (int) (Double.parseDouble(lngLat[1]) * 1E6), (int) (Double.parseDouble(lngLat[0]) * 1E6)); if (gp2.getLatitudeE6() != 22200000) { geoPoints.add(gp2); } } } totalNumberOfOverlaysAdded++; mMapView01.getOverlays().add(new RoutePathOverlay(geoPoints)); } } catch (NumberFormatException e) { Log.e(BikeApp.APP, "Cannot draw route.", e); } } } Log.d(BikeApp.APP, "Total overlays: " + totalNumberOfOverlaysAdded); mMapView01.setEnabled(true); } @Override protected boolean isRouteDisplayed() { // TODO Auto-generated method stub return false; } } Edit: There are of course some more files I'm using but that I have not posted. You can download the complete Eclipse project here: http://danielkvist.net/se.zip

    Read the article

  • How to get left-top and right-buttom latitude and longitude of map in MapKit For iPad ?

    - by damniatx
    Hi, i'm looking for answer about getting latitude and longitude from uimapkit. there is same problem that has been answered, but it didn't give right coordinate. http://yit.me/3ddp73 it's code from thread i'm linking above. CLLocationCoordinate2D topLeft, bottomRight; topLeft = [mapView convertPoint:CGPointMake(0,0) toCoordinateFromView:mapView]; CGPoint pointBottomRight = CGPointMake(mapView.frame.size.width, mapView.frame.size.height); bottomRight = [mapView convertPoint:pointBottomRight toCoordinateFromView:mapView]; NSLog(@"topleft = %f", topLeft); NSLog(@"bottom right = %f", bottomRight); any idea to fix this issue ? thanks

    Read the article

  • OsmDroid show blank screen with blocks

    - by Lennie
    Am trying to use OsmDroid with MapQuest maps downloaded from Mobile Atlas Creator. I followed all the instructions to generate the map tiles, upload them to the SDcard etc but when I run this on the device I get a screen with a bunch of empty boxes... What am I doing wrong? > @Override > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > setContentView(R.layout.osm_map); > mapView = (MapView) findViewById(R.id.mapview); > mapView.setTileSource(TileSourceFactory.MAPQUESTOSM); > mapView.setBuiltInZoomControls(true); > mapView.setUseDataConnection(false); > mapController = mapView.getController(); > mapController.setZoom(15); > } > protected boolean isRouteDisplayed() { > // TODO Auto-generated method stub > return false; > }

    Read the article

  • Refreshing a MKMapView when the user location is updated or using default values

    - by koichirose
    I'm trying to refresh my map view and load new data from the server when the device acquires the user location. Here's what I'm doing: - (void)viewDidLoad { CGRect bounds = self.view.bounds; mapView = [[MKMapView alloc] initWithFrame:bounds]; mapView.showsUserLocation=YES; mapView.delegate=self; [self.view insertSubview:mapView atIndex:0]; [self refreshMap]; } - (void)mapView:(MKMapView *)theMapView didUpdateUserLocation:(MKUserLocation *)userLocation { //this is to avoid frequent updates, I just need one position and don't need to continuously track the user's location if (userLocation.location.horizontalAccuracy > self.myUserLocation.location.horizontalAccuracy) { self.myUserLocation = userLocation; CLLocationCoordinate2D centerCoord = { userLocation.location.coordinate.latitude, userLocation.location.coordinate.longitude }; [theMapView setCenterCoordinate:centerCoord zoomLevel:10 animated:YES]; [self refreshMap]; } } - (void)refreshMap { [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES]; [self.mapView removeAnnotations:self.mapView.annotations]; //default position NSString *lat = @"45.464161"; NSString *lon = @"9.190336"; if (self.myUserLocation != nil) { lat = [[NSNumber numberWithDouble:myUserLocation.coordinate.latitude] stringValue]; lon = [[NSNumber numberWithDouble:myUserLocation.coordinate.longitude] stringValue]; } NSString *url = [[NSString alloc] initWithFormat:@"http://myserver/geo_search.json?lat=%@&lon=%@", lat, lon]; NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:url] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0]; [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; [url release]; [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO]; } I also have a - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data, to create and add the annotations. Here's what happens: sometimes I get the location after a while, so I already loaded data close to the default location. Then I get the location and it should remove the old annotations and add the new ones, instead I keep seeing the old annotations and the new ones are added anyway (let's say I receive 10 annotations each time, so it means that I have 20 on my map when I should have 10). What am I doing wrong?

    Read the article

  • iPhone MapKit problems: viewForAnnotation inconsistently setting pinColor?

    - by blackkettle
    Hi, I'm trying setup a map that displays different pin colors depending on the type/class of the location in question. I know this is a pretty common thing to do, but I'm having trouble getting the viewForAnnotation delegate to consistently update/set the pin color. I have a showThisLocation function that basically cycles through a list of AddressAnnotations and then based on the annotation class (bus stop, hospital, etc.) I set an if( myClass == 1){ [defaults setObject:@"1" forKey:@"currPinColor"]; [defaults synchronize]; NSLog(@"Should be %@!", [defaults objectForKey:@"currPinColor"]); } else if( myClass ==2 ){ [defaults setObject:@"2" forKey:@"currPinColor"]; [defaults synchronize]; NSLog(@"Should be %@!", [defaults objectForKey:@"currPinColor"]); } [_mapView addAnnotation:myCurrentAnnotation]; then my viewForAnnotation delegate looks like this, - (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id )annotation { if( annotation == mapView.userLocation ){ return nil; } NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; MKPinAnnotationView *annView = nil; annView = (MKPinAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:@"currentloc"]; if( annView == nil ){ annView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"]; } annView.pinColor = [defaults integerForKey:@"currPinColor"]; NSLog(@"Pin color: %d", [defaults integerForKey:@"currPinColor"]); annView.animatesDrop=TRUE; annView.canShowCallout = YES; annView.calloutOffset = CGPointMake(-5, 5); return annView; } The problem is that, although the NSLog statements in the "if" block always confirm that the color has been set, the delegate sometimes but not always ends up with the correct color. I've also noticed that what generally happens is that the first search for a new location will set all pins to the last color in the "if" block, but search for the same location again will set the pins to the correct color. I suspect I am not supposed to usen NSUserDefaults in this way, but I also tried to create my own subclass for MKAnnotation which included an additional property "currentPinColor", and while this allowed me to set the "currentPinColor", when I tried to access the "currentPinColor from the delegate method, the compiler complained that it didn't know anything about "currentPinColor in connection with MKAnnotation. Fair enough I guess, but then I tried to revise the delegate method, - (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id )annotation instead of the default - (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id )annotation at which point the compiler complained that it didn't know anything about the protocol for MyCustomMKAnnotation in this delegate context. What is the proper way to set the delegate method and/or MyCustomMKAnnotation, or what is the appropriate way to achieve consistent pinColor settings. I'm just about out of ideas for things to try here.

    Read the article

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