android-mapview

How to draw at the current GPS location on MapView using MyLocationOverlay?

て烟熏妆下的殇ゞ 提交于 2019-12-01 01:09:19
I'm trying to draw a custom gps-location icon. I'm using MapView and have created a class MyLocationArrow that extends MyLocationOverlay . I override drawMyLocation() and draw a point at 100,100. But this is the coordinates on screen. How do I get the screen-coordinates from the current GPS-location? NickT You can use android.graphics.Point toPixels(GeoPoint in, android.graphics.Point out) Converts the given GeoPoint to onscreen pixel coordinates, relative to the top-left of the MapView that provided this Projection . . 来源: https://stackoverflow.com/questions/4624993/how-to-draw-at-the-current

Google Maps Android MapView v2: disable zooming

∥☆過路亽.° 提交于 2019-12-01 00:02:52
问题 Is there a way to disable the zooming (pinch and double tap) in the MapView but keep the scrolling? This means setting clickable to false would not work. I have also tried setting an onTouch listener in the activity but it will not trigger using: mapView.setOnTouchListener(this); 回答1: You can assign those properties using the XML file: map:uiRotateGestures="true" map:uiScrollGestures="true" map:uiTiltGestures="true" map:uiZoomGestures="true" So use: map:uiZoomGestures="false" On the

MapView.onMapReady never called in Fragment for load Google Map in MapView

…衆ロ難τιáo~ 提交于 2019-11-30 22:43:22
I'll try to show a map in my Android application on a fragment named RoeteFragment . If I debug my code I see that the method onMapReady is never called so that the map will not load. The fragment implements OnMapReadyCallback like needed and in the onCreateView I get the MapView and call getMapAsync . If I place a breakpoint on that method, it will always been hit, the breakpoint inside onMapReady never been hit. There is no exception thrown. I've also a valid Google Maps API key in the file res/values/google_maps_api.xml . Here is my code: <?xml version="1.0" encoding="utf-8"?>

Distance between two location in Android map

前提是你 提交于 2019-11-30 20:32:12
问题 How to calculate distance between 2 location in android map & output must display in textview or any ? 回答1: For those people like me, who are learning now/late. Have made use of the code written by @NaserShaikh below. Here you go a working code to get driving distance on google map when u have lat,long of two points!! distance is in miles ! There are better way to parse the JSON response pls look for it. Havent tested it for extremes when there is a ocean btw and other stuffs. Hope it helps.

Android MapView does not load unless you touch on the mapview

别来无恙 提交于 2019-11-30 18:28:34
I have added a mapview in my android application.I have used correct settings in the manifest and now i'm facing a problem. When i go to the place where i have my map,it displays only the canvas but not the map. If i touch on it only it starts loading. Even then it does not fully load.it loads only to a certain level.if i keep touching the screen it continuously loads. But even then i cannot zoom in or out OR cant even move the map. Is there a solution for this? Have i done something wrong? My Code MapView mapView; GoogleMap map; mapView = (MapView)view.findViewById(R.id.map); Bundle

MapView adding pushpins on touch

北城余情 提交于 2019-11-30 18:18:31
I managed to get the map shown on the screen. Now the user will move around the map and press on it. After pressing on a point I need to add a push pin on screen on the pressed location. If the user decides to go for another point, when pressing on the chosen point, the first pushpin would disapear and a new one will be drawn on the new location I did like this: public class LocationSelectionActivity extends MapActivity { GeoPoint p; List<Overlay> listOfOverlays; MapOverlay mapOverlay; private MapView mapView; /** Called when the activity is first created. */ @Override public void onCreate

draw is being constantly called in my android map overlay

折月煮酒 提交于 2019-11-30 17:52:48
I'm trying to draw a route onto my MapView. I've extended Overlay and implemented the draw() method. The route is displayed properly, although while debugging, I added a breakpoint on draw(), and noticed it is being called constantly. I only want it to be re-drawn if someone moves the map or zooms (the draw take into account these changes when drawing the route) What can cause this ? There are two draw methods that can be overridden. void draw(android.graphics.Canvas canvas, MapView mapView, boolean shadow) Desc: Draw the overlay over the map. boolean draw(android.graphics.Canvas canvas,

Call functions of Activities Belonging to a Fragment

走远了吗. 提交于 2019-11-30 16:45:31
I am working with multiple Fragments under Android and am confused on how to send and receive data from embedded apps. For a simple explanation, I have a ListFragment and a MapFragment using the method explained here . This means that the List lives in the ListFragment class, however the MapActivity is an Activity that is called under the LocalActivityManagerFragment . Everything works on the individual Fragments : Lists of waypoints, waypoints and current location implemented on the MapFragment . I also understand how to use getFragmentManager() to get individual Fragments and use their

Calculate the area covered by a polygon in a google map in an Android App

∥☆過路亽.° 提交于 2019-11-30 16:20:45
I've got a series of Location / GeoPoint objects that form a polygon in my Android app. I wonder if there's any way to calculate the area covered by it. So far I'm thinking about setting up a web service that, when posted the list of coordinates, uses the JS Google Maps API v3 to calculate the area. But there might be a way of doing this easily with some feature from Android I don't know about, natively. Thanks in advance for your help! L. G. A method doing this is posted in following answer: https://stackoverflow.com/a/16210785/891479 This is based on following formula: http://mathworld

How to add a map scale in MapView on Android?

送分小仙女□ 提交于 2019-11-30 16:04:50
I'm struggling with adding a map scale that displays current length on screen depending on current zoom level. I'm having a feeling that it might exist some predefined class to use but I have no clue...? I've searched around a lot but can't find anything. Any help i much appreciated =) // Alex Alright, I got it now! Luis answer helped me a lot and also OpenStreetMap. Here's what I came up with: <your.own.package.path>; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Matrix; import android.graphics.Paint; import android