I've built my app layout and it's all looking good to me about where my things will go. I'll put a screenshot of the one fragment in which I want to place a small google map API.
I want the google map in the button which says "MAP". I'm fairly new to android development and would really appreciate it if someone could help me out with this and/or send me links to the videos that talk about exactly what I want because everything that I've tried searching for is either not necessary or not what I want.
Here's my page;
I want to add a map to the 'MAP' button that is clickable and will take me to google maps or if that's not considered 'API', I want it to become full screen. I'd prefer if it takes me to google maps though.
Thanks a lot for the help!
The basic steps for adding a map are:
You need to set up your API key and Gradle dependencies.
https://developers.google.com/maps/documentation/android-sdk/config
Add a Fragment object to the Activity that will handle the map. The easiest way to do this is to add a element to the layout file for the Activity.
Implement the OnMapReadyCallback interface and use the onMapReady(GoogleMap) callback method to get a handle to the GoogleMap object. The GoogleMap object is the internal representation of the map itself. To set the view options for a map, you modify its GoogleMap object.
Call getMapAsync() on the fragment to register the callback.
Please go through this link to get you started: https://developers.google.com/maps/documentation/android-sdk/map
Related
I need to generate thumbnails of different maps so they can be displayed in a list, which gives an overview over all available maps in my App.
For the generation of a map screenshot I found the snapshot-method in GoogleMap.
Now I would like to run the thumbnail Generation in a background thread.
According to the documentation you need to call getMapon a MapViewor a MapFragment to instantiate a GoogleMap.
Is there a different way of getting hold of a GoogleMap-Object, instead of using the View or the Fragment? Is there something like a OffScreenRenderer that would allow to use the GoogleMap without actually displaying it on the Screen and ideally running it not in the MainThread?
For thumbnails I use Static Maps API V2 and Android-Universal-Image-Loader.
But you want to show those list thumbnails some time in the future, right? If yes then generate them when showing (and cache after showing).
I'm using version 1.3.1 of the Google Maps Extension and am trying to exclude a marker from being clustered. I have one marker that is set in the onCreate method of my app and it represents My Location. I want this to always be visible and not be clustered like the rest of my markers. Is this possible? I tried adding the marker before I set the clustering settings and before I called setClustering on the GoogleMaps object, but it doesn't seem to work.
If you are using just one Marker which should not be clustered with all other, you can see a workaround in comment #2 here:
https://code.google.com/p/android-maps-extensions/issues/detail?id=10#c2
Basically using SupportMapFragment.getMap().addMarker(...) instead of SupportMapFragment.getExtendedMap()
The problem is you will get null in GoogleMap callbacks like onMarkerClick, but for just one Marker you can find out it's "the Marker". Clustering engine will not be aware of Marker added that way.
You will also have class name collision, so you have to use full class name for original library like com.google.android.gms.maps.model.Marker in case you keep a reference to this Marker.
Hope it helps until this improvement is implemented.
Edit:
This is available as of version 1.5 via simple call:
theMarker.setClusterGroup(777);
The default group is 0 and only Markers with the same group are clustered together, so if you change one Marker's group, you'll get the desired effect.
In my ExpandableListView I need to add Google Map on each item.
I tried with putting Map on each item but its giving me inflate exception. And its is also stated that an MapActivity can contain only one MapView.
Is there any other idea to achieve this.
For refrence you can see here.
Your comments regarding MapActivity indicate that you are using Maps V1, which is deprecated. Maps V2 does not require a MapActivity and can have multiple maps.
That being said, your proposed implementation is unlikely to work well, as putting scrollable things in scrollable things can be problematic. It also is rather unrealisitc IMHO -- whoever came up with that design has never used an actual smartphone, as there's no point in having an interactive map that small (again, IMHO).
Consider using static maps (there's a Google API for that somewhere) for inside the ExpandableListView, where a tap on the map brings up the full map, either in your app or in the standard Maps app.
I recommend to not use static map (as for example it's not possible to zoom to particular bounds with newLatLngBounds or add a circle in particular lat/lon).
I recommend to use map fragment in lite mode:
In addition, there is also a new ‘lite mode’ map option, ideal for situations where you want to provide a number of smaller maps, or a map that is so small that meaningful interaction is impractical, such as a thumbnail in a list. A lite mode map is a bitmap image of a map at a specified location and zoom level.
Map fragment can be nested in the list.
I am not sure whether I should be using MapView or stick to using a MapFragment. My application is an app that finds the nearest set of places that are closest to you. I want to be able to add locations, display details of a marker when I press a marker and when the user moves along the map I want to be able to get the coordinates of the center of the map and display the nearest locations within a defined radius. Would I be at a disadvantage if I continue to use MapFragments or should I switch over to MapView while I still have the chance?
First of all, soon the MapView and Google Maps API V1 will stop being supported and won't receive any new updates. And soon all the support will go away.
Secondly, MapFragment may be a little bit less flexible right now, but the map presented, manipulated a looks much better. And I guess that it's functionality will improve with time.
So I would definitely continue to use MapFragments.
UPDATE:
As #Brian White pointed out in the comments, today there is a MapView in Google API V2, and you should use it when you want to embed a map in a fragment. That way you will avoid cascading fragments when you don't have to.
MapFragment
Use it if you want to add a map into Activity class (not fragment
because it will create a nested fragment and it´s a mess).
Use SupportMapFragment if you want to support just android versions
lower than v12.
MapView
Use it if you are going to add a map into a fragment. (you need to
update each lifecicle to MapView).
i want to do the following. I am having a google map that displays my position. I have created separately a compass. Now what I want is to combine them and put the compass on top of my map. I do not know where to start for it, and how I skould implement it since data of te compass are also being updated every second I move?
If you have any tutorials please give me link cause I have not been able to find any.
In my previous app I have used a class extending Overlay but this was for only putting a pin or something like this.
You may add the image as a custom control: example (it's the home-button in the example)