iOS – How to limit the MapView to a specific region?

After trying different ways of limited MKMapView I’ve concluded that using mapDidChange, and resetting if you’re center point goes outside of the boundaries works best, with animated: YES Here’s how I do it (Using the New Zealand lat/Long span/center). – (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated{ if ((mapView.region.span.latitudeDelta > 15.589921 ) || (mapView.region.span.longitudeDelta > 175.836914) ) { CLLocationCoordinate2D … Read more

How to draw dashed polyline with android google map sdk v2?

Now in Polyline you can set the pattern to be Dash, Dot or Gap simply apply the following public static final int PATTERN_DASH_LENGTH_PX = 20; public static final int PATTERN_GAP_LENGTH_PX = 20; public static final PatternItem DOT = new Dot(); public static final PatternItem DASH = new Dash(PATTERN_DASH_LENGTH_PX); public static final PatternItem GAP = new … Read more

android MapView in Fragment

From Josh Holtz’s example on GitHub: You should add MapView in your Layout like <com.google.android.gms.maps.MapView android:id=”@+id/mapview” android:layout_width=”fill_parent” android:layout_height=”fill_parent” /> and implement your Fragment like public class SomeFragment extends Fragment { MapView mapView; GoogleMap map; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.some_layout, container, false); // Gets the MapView from … Read more

How does one implement drag and drop for Android marker?

Implement Google Maps Android API v2, refer this: https://developers.google.com/maps/documentation/android/ and set on GoogleMap object setOnMarkerDragListener. For Ex: map.setOnMarkerDragListener(new OnMarkerDragListener() { @Override public void onMarkerDragStart(Marker arg0) { // TODO Auto-generated method stub Log.d(“System out”, “onMarkerDragStart…”+arg0.getPosition().latitude+”…”+arg0.getPosition().longitude); } @SuppressWarnings(“unchecked”) @Override public void onMarkerDragEnd(Marker arg0) { // TODO Auto-generated method stub Log.d(“System out”, “onMarkerDragEnd…”+arg0.getPosition().latitude+”…”+arg0.getPosition().longitude); map.animateCamera(CameraUpdateFactory.newLatLng(arg0.getPosition())); } @Override public void … Read more

Double tap: zoom on Android MapView?

I’ve also been searching for an answer/example, but found nowhere working code. Finally, here’s the code that’s working for me: MyMapActivity.java public class MyMapActivity extends MapActivity implements OnGestureListener, OnDoubleTapListener { private MapView mapView; @Override public void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); setContentView(R.layout.main); mapView = (MapView)findViewById(R.id.mapView); } @Override public boolean onDoubleTap(MotionEvent e) { int x = … Read more

Android draw route on a Mapview with twoo POI-s

go through this codes. Modify the code as per ur requirement MapDirection.java: public class MapDirection extends MapActivity{ MapView mapview; MapRouteOverlay mapoverlay; Context _context; List<Overlay> maplistoverlay; Drawable drawable,drawable2; MapOverlay mapoverlay2,mapoverlay3; GeoPoint srcpoint,destpoint; Overlay overlayitem; public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setContentView(R.layout.map_direction); RegisterActivities.registerActivity(this); mapview=(MapView)this.findViewById(R.id.mapview); callMap(); } private void callMap() { srcpoint=new GeoPoint((int)(Data.src_lat_date*1E6),(int)(Data.src_long_data*1E6)); maplistoverlay=mapview.getOverlays(); drawable=this.getResources().getDrawable(R.drawable.green_a); mapoverlay2=new MapOverlay(drawable); … Read more