android-mapview

How to compute a radius around a point in an Android MapView?

爷,独闯天下 提交于 2019-11-28 18:26:59
I have a MapView that I'm displaying a "useful radius" (think accuracy of coordinate) in. Using MapView 's Projection 's metersToEquatorPixels , which is admittedly just for equatorial distance) isn't giving me an accurate enough distance (in pixels). How would you compute this if you wanted to display a circle around your coordinate, given radius? So, Google Maps uses a Mercator projection . This means that the further you get from the equator the more distorted the distances become. According to this discussion , the proper way to convert for distances is something like: public static int

Android Mapview: Merging overlapping markers into a new marker

℡╲_俬逩灬. 提交于 2019-11-28 17:20:02
So I have a MapView with a lot of markers, most of which are concentrated in mile wide clusters. When zoomed the markers overlap and appear to only be one. What I want to achieve is at a certain zoom level replace the overlapping markers with a group marker that will display the density of markers and onClick will zoom to display all markers inside. I know I can do this with brute force distance measurements but there must be a more efficient way. Anyone have any solution or smart algorithms on how I can achieve this? Um... assuming the markers are not grouped, layered or anything: why -

Placing Zoom Controls in a MapView

空扰寡人 提交于 2019-11-28 16:34:48
I'm trying to get the zoom controls to show up in a mapview , the following code almost works, but the zoom controls appear in the top left of the mapview , not the bottom center like I'm specifying via setGravity() . Can someone enlighten me as to what I'm missing? zoomView = (LinearLayout) mapView.getZoomControls(); zoomView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT)); zoomView.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL); mapView.addView(zoomView); These views/layouts are all constructed programmatically,

Android Google Maps: XML layout errors

↘锁芯ラ 提交于 2019-11-28 14:40:11
I am trying to get google maps v2 to work in android using android studio. I got all my keys and manifest setup. When I try and create xml for the actual activity that the map will show up on I get errors. My xml looks like this: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" > <fragment xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/map" android:layout_width="match_parent" android:layout

Android Render Google Map inside a Fragment

空扰寡人 提交于 2019-11-28 11:08:30
问题 As shown above i have a Fragment Activity which renders two fragements. On the Map Fragment i want to implment and display a Map. Since we need to extend MapActivity i am not sure how it can be done inside a fragment. Trying to implement Solution from (https://stackoverflow.com/a/10739200/1737771) package com.m7.nomad; import android.app.LocalActivityManager; import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android

How to get the Latitude and Longitude on Map in Android?

对着背影说爱祢 提交于 2019-11-28 10:56:12
How can I get the Latitude and Longitude values of a particular location that I have long clicked on the map in Android? For the long click, I suggest you check out http://www.kind-kristiansen.no/2010/handling-longpresslongclick-in-mapactivity/ . This will go into detail on how to listen for long click events within the Maps API since there is little or no built-in functionality that I know of. As for the lat/lng code, after you get the long click you can translate the pixels to coordinates. public void recieveLongClick(MotionEvent ev) { Projection p = mapView.getProjection(); GeoPoint

How to retrieve current device location & show it on map fragment in a fragment

依然范特西╮ 提交于 2019-11-28 10:28:20
I'm developing a android app with google maps. Currently I'm able to view the map inside my app, but I don't know how to view the current location on the app. Here is my code: public class MapsFragment extends Fragment{ MapView m; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // inflat and return the layout View v = inflater.inflate(R.layout.map_near_me, container, false); m = (MapView) v.findViewById(R.id.map); m.onCreate(savedInstanceState); return v; } } Edited: And the xml: <LinearLayout xmlns:android="http://schemas.android

Android - drawing path as overlay on MapView

别说谁变了你拦得住时间么 提交于 2019-11-28 10:23:11
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

MapView in Fragment ( Android 4.0 or higher)

十年热恋 提交于 2019-11-28 10:22:19
I've been looking for a while to find a good tutorial with code example for a MapView in Fragment for ICS. Anyone have any links? Here is a book's sample application showing how to have a MapView in a Fragment in an API Level 11+ app. It's mostly just a MapActivity . Here are the key bits of the fragment that loads the MapView : public class MapFragment extends Fragment { private MapView map=null; private MyLocationOverlay me=null; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return(new FrameLayout(getActivity())); } @Override

Draw driving route between 2 GeoPoints on GoogleMap SupportMapFragment

為{幸葍}努か 提交于 2019-11-28 09:33:26
This is a tricky question, been banging my head for a day, please help. I use Google Maps Apis to get the shortest driving distance and its routes, points, etc between 2 GeoPoints that I provide, see code below private JSONObject GetDistance(String src, String dest) throws Exception { StringBuilder urlString = new StringBuilder(); urlString.append("http://maps.googleapis.com/maps/api/directions/json?"); urlString.append("origin=");// from urlString.append(src); urlString.append("&destination=");// to urlString.append(dest); urlString.append("&mode=driving&sensor=true&units=imperial"); // get