I've got a place I want to add on my map at a particular lat / lng. I'd like to display that on my map when the activity starts. How would I do this?
Thanks.
This Google/Android tutorial should provide exactly the information you need.
Basically you create an custom ItemizedOverlay, grab a list of overlays from the MapView (getOverlays), create some GeoPoints and your set.
The Google Maps library documentation is a great reference for map related questions.
Related
I want to make a custom notification with big style but i don't know how to insert google map with path and multiple marker like below image please help.
You will want to use the google static maps API.
https://developers.google.com/maps/documentation/static-maps/intro#Markers
The link above will direct you to the markers sections. There you can read about how to use custom markers.
By using the above API you will eventually get a map bitmap, that can easily be used inside the notification.
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 need to create some custom polygon overlays on my map and by custom I mean I need to add more information to the overlay so that when it gets clicked I can show a dialog or something with information about the overlay.
I have done a little reading and it looks like the Overlay and ItemizedOverlay classes were removed from the API v2 in the form of Polygons,Polylines etc...
In order to create a custom overlay it looks like I have to create a View on top of the map and just draw on the view but some of my polygons might not be visible for the current map projection
Is there anyway to assign an id to the polygon class or something so that I know what was clicked so I can get the information?
First of all GMaps Android API v2 doesn't provide a callback for when a polygon is clicked. You would have to use onMapClick and use point inside polygon algorithm iterating over all polygons.
If you keep Map you can iterate over keys and if you have a match, get the value.
Alternatively you may want to try Android Maps Extensions, which has a GoogleMap.getPolygons() for you to iterate over and Polygon.setData(Object) + Polygon.getData() to assign any additional data and retrieve it when you find a match using point inside polygon algorithm.
I would like to ask about how can I add different overlays to my android application?
as I already have one overlay class that extends Overlay and it draws polylines according to some points in a KML file.
and now I would like to create another overlay that adds a pin in the user's location using GPS, so I don't know how this could be done.
please anyone knows how to help me ?
thank you in advance.
You can have multiple overlays on top of one map.
Just create the second layer as an ItemizedOverlay, and add it to the map:
myMapView.getOverlays().add(myItemizedOverlay);
To learn how to add markers to an ItemizedOverlay, see http://android-coding.blogspot.com/2011/06/using-itemizedoverlay-to-add-marker-on.html.
To add a pin to the user's location use MyLocationOverlay it's in the google maps API see this link
Android GoogleMaps API Documentation may also help.
I have the map working on android and am able to populate it with overlays.
But the overlay ability is only so good. If I add too many overlays and refresh too often, I can create an app that is very processor-hard (useless).
What I want to do is only load the overlays that are within the zoom level of the map.
How to I get at what level the map is zoomed using Google APIS, overlays, itemized, and geopoints?
Thanks,
You can use the getZoomLevel and getMapCenter methods on MapView. You might also read through the MapView class documentation.
You can directly get that from class without any method.
map.getCameraPosition().zoom