modify polygon in android google map api - android

I started Google map in android few days age. I am doing some basic things like set marker on tap, draw line between two marker etc.
Here users can draw polygon with tapping on the device. Now i want to edit the shape. I goggled it but didn't find any helpful solution for android.
I found some resource on google map java script API like user-editable-shapes in javascript
I want to do the same in android. How to Edit or Modify polygon in Google Map Android API
It will be helpful if u provide some resource.

It looks to me like you have to replace all the points at once with setPoints on the polygon object.
https://developers.google.com/android/reference/com/google/android/gms/maps/model/Polygon.html#setPoints(java.util.List)
I'm currently trying to do the same thing in Xamarin. I mock up an edit mode when the user clicks on the polygon by changing its stroke color and then adding custom markers to each vertex. I'm holding a selected vertex which will move to the user's next click on the map and update the polygon.

Related

Highlight all the worlds in Android Google Maps

I'm developing an app in which the user can select points on a Google Maps and create areas based on point-radius and display them on the map with a semi-transparent circle of a specific color. The user is also able to insert "all world" areas. I need to display this "all-world" area on the map, is it possible to add a semi-transparent polygon that cover all the map? Or, is there a better solution to highlight all the map?
Check the documentation of Polygons under the Shapes in Google Maps Android API to cover the map.
Polygon objects are similar to Polyline objects in that they consist of a series of coordinates in an ordered sequence. However, instead of being open-ended, polygons are designed to define regions within a closed loop with the interior filled in.
To create Polygon, first create a PolygonOptions object and add some points to it. These points will form the outline of the polygon. You then add the polygon to the map by calling GoogleMap.addPolygon(PolygonOptions) which will return a Polygon object.
To alter the shape of this polygon, just call the Polygon.setPoints() and provide a new list of points for the outline of the polygon.
Now, for customizing the appearance of the polygon, just check this link. And for the semi-transparent polygon that you want, you can check these tutorial and SO question on how to achieve that.

Show area covered by a pincode on Google maps.[Android]

I want to implement a code in android to show area covered by a PINCODE that is six digit area code on google map as shown in the screenshot attached.
Kindly provide a way how can I accomplish this thing.Thanks in advance.
You can try the Google Maps Geocoding service to locate the area or region that you type in your maps. Geocoding is the process of converting addresses into geographic coordinates, which you can use to place markers or position the map.
Geocoding has a required parameter address that you need to supply in order for it to locate/geocode the address that you type. And this address supports the postal_code that you want to search.
Although this code is in JavaScript, here is the link for the example code and how to use Geocoding.
For the area part that you want to return when searching postal_code, I think you can use Polygons.
A polygon represents an area enclosed by a closed path (or loop), which is defined by a series of coordinates. Polygon objects are similar to Polyline objects in that they consist of a series of coordinates in an ordered sequence. Polygons are drawn with a stroke and a fill. You can define custom colors, weights, and opacities for the edge of the polygon (the stroke) and custom colors and opacities for the enclosed area (the fill).
For more information about Polygons, Check this example and the above link for documentation.
Also check this sets of link that may give you an idea.
How do I show the boundaries of postcodes on google maps?
How do I highlight any area boundary on Google Maps?
Google Maps Highlight a particular area
Currently Google Maps APIs do not expose the boundaries of postal codes areas.
There is corresponding feature request in public issue tracker:
https://code.google.com/p/gmaps-api-issues/issues/detail?id=4008
However, it looks like Google didn't set a priority on this task.
UPDATE
As #kaskader mentioned I posted a link for Maps JavaScript API feature request. Sorry for confusion.
Please have a look at another answer where you can find a workaround for your question.
https://stackoverflow.com/a/43918793/5140781

Drawing on the MapFragment, while keeping some elements visible

I'm developing an application that has the following goal:
Using the google maps android API 2 I get my current position, and as I start walking the application starts drawing the route I take
The twist is that the map is a "blind" map. Meaning the map is hidden, only the Marker of my current position and a dotted line of my route is shown.
Keep in mind I'm a novice developing to Android, so please be specific. (Thank you)
I managed to create the map, get my current position and zoom in to it (Had no sens to see the whole planet while i want only my current position). And it's pretty accurate so far.
The thing is I don't know what should I do from this point on.
Basicly I need a white View between the Marker and the real map. Also as I advance that View should always be on, over the MapFragment/MapView. Also I wish to keep the zoom and drag functionality's of the MapFragment.
How can I achieve this?
At this point I'm opened to any solutions.
(Been browsing for a few days now the developers site, I have seen that with the ViewOverlay class I can put messages over the map, but I'm not sure what would the correct aproach be in my case...)
To hide the whole map behind the white view I would use Polygon class Polygon Even if you specify Polygon to cover the whole map Markers will be still displayed in front of it and as so user's current position marker will be visible. You also will be able to zoom and drag.
To draw line on map use Polyline class Polyline It will draw users path as a polyline. If you want to stick with dotted line you can use Circle objects to create it. Circle

Label at the top of the marker in google maps api v2

One more problem while switching to the maps api v2.
This is an ugly representation of what i want to achieve.
Edit1. There can be several markers, every marker with its own label. All markers and labels are shown simultaneously.
As you can see there is a label with some information at the top of the marker.
While using api v1 it can easily be done with drawing marker and label on Overlay.
How can I implement it using api v2?
The first idea is to render marker(red) and label(black) to one bitmap and set it as marker. But it will significantly increase marker area(red rectangle) and with this marker limitation gives me real headache with user to map interraction realisation.
The second idea is to use GroundOverlay, but at first glance, it is not designed for this purpose.
Edit2 Here is similar question, solution, like in the first idea, is to use both marker and label as single marker bitmap, created from view.
Have a look at a library I am working on:
googlemaps/android-maps-utils
You can use the BubbleIconFactory to achieve this:
IconGenerator factory = new IconGenerator(this);
Bitmap icon = factory.makeIcon("11:15 1.08.2013");
mMap.addMarker(new MarkerOptions().position(...).
icon(BitmapDescriptorFactory.fromBitmap(icon)));
This is much simpler to do on Android Maps v2. Please take a look at the official documentation here: https://developers.google.com/maps/documentation/android/marker
It is called Info Window. By default, an info window is displayed when a user taps on a marker and if the marker has a title set

Android custom GPS map application

I want to build an app that uses GPS data and a building map I provide to show the user where in the building on the map they are. This will be done in a specific building that i already know gets GPS and cell service.
At first I thought the easiest way to do this was to see if I could use Google maps to plot the users location and then just "overlay" my custom building map on top of the Google map so that I wouldnt have to deal with any of the gps information or the complexities of the mapping I would just have to scale my "overlay" to fit properly on top of the Google map so that the user was shown in the correct room in a building. I'm wondering if anyone can provide me any information on how to do this or if there is an easier way to accomplish my map. Any information at all is helpful!
You want...
Google Map View
...and more specifically you will probably want to read the subsection appropriately titled: "Part 2: Adding Overlay Items"
EDIT: Whoops! Nevermind! I misread your question... that is only if you want to overlay an item on the map. Sorry...
There is no possibility to use closer zoom level than that you can see on standard GMap i.e. in browser. Other problem is that google uses GeoPoint class based on cardinal microdegrees to draw overlays, and it's accuracy is to low.
You can look on jGarminImg - it's java library - unfortunately written for using with swing, but it should be relatively easy to make it work with android. On the other hand - you have to make your own map.
You can use standard overlays, or you can make your map in kml format and use this example to display it.
You may be able to achieve this with a custom view that displays your building plan and knows the precise co-ordinates of each corner of the building.
When you receive your location updates you can add a marker to your custom view by translating the real world position into a position in the image using something along the lines of:
pseudocode:
markerX = realWorldX - mapStartX;
markerY = realWorldY - mapStartY;
if( isOnMap( markerX, markerY ) )
{
drawMarker( markerX, markerY );
}
Yes you can overlay bitmap images on top of the Google MapView.
All you have to do is subclass the Overlay class, override the draw method, and draw on the canvas. You have to provide a rectangle of GeoPoints (probably the top left and the bottom right corners) to anchor the building bitmap on top of the MapView. You use mapView.getProjection() to translate the latitude and longitude into xy coordinates on the canvas.
I assume drawBitmap(Bitmap bitmap, Rect src, RectF dst, Paint paint) will be useful here. Bear in mind that src and paint can be null. If the GeoPoints you used are accurate, the bitmap will adjust automatically to pans and zooms, although it might get pixelated if the user zooms in too much.
edit: I am not so confident that Google Maps will have your building stays at the exact same GeoPoints in different zoom levels, so you might have to adjust those values for different zoom levels
If you need only the map of the building, it should not be too difficult to plot the location on an image without using Google Maps, provided that you can determine your location as coordinates inside the building.
You need to know two coordinates: north-west and south-east corners of the building map you are using. When you get GPS location updates, the correct location on the map image can be easily calculated based on these corner coordinates.
I would do it like this,
Place a marker on the google map to indicate the position of the building
Drilling down on the building would load your building map as a custom view. Plot the user location on the custom view
I think trying to overlay your building map on a google map while possible will be more complex to code than doing it via a custom view.
Also overlaying the lowest zoom level with your building map is not going to give you enough resolution unless you have a thumping big building. Whole blocks are pretty small
One issue you have probably already considered is the device will revert to cell tower and wifi for it's location when inside the building giving you a less accurate location fix.

Categories

Resources