I need to highlight a certain continent in google map by some color.
I read about Polygon, but what i need is just determine continent name.
Can somebody help me?
You would use draw a polygon over the desired area. To do this, you'll need the coordinate data for whatever you want to overlay. There are various tools and resources online which can help you get that data, like here.
Alternatively, you can apply a GroundOverlay to the area you wish to highlight. You place an image onto your map at a defined location. The image will rotate, tilt, or zoom along with your map. You can also set the transparency of the image, if necessary.
Related
I have a Google map were I draw rectangles.
I have a draggable marker that makes the rectangle change is size as you move your finger.
I do polygon.remove and then create a new polygon with new points (one of the corners is the marker position and I calculate the others)
The resize is working, but the problem is that graphics are slow, you can see the polygon dissapear and reappear.
Is it because of a hardware limitation or there's another better approach?
From the documentation of Google Maps Android API, it is stated in the Polygon part here that to alter the shape of the polygon after it has been added, you can call Polygon.setPoints() and provide a new list of points for the outline of the polygon.
So you must update the shape by calling Polygon.setPoints() rather than adding/removing it.
For more information, just check the link above.
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.
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.
I'm trying to write an Android app that will allow a user to search for a generic destination (e.g., "gas station") and be presented with up to ~5 nearby locations to choose from. The screen results would display the user location in the center, and possible destination options would be indicated by markers.
The trick is that I don't want to rescale the map from its starting scale, and so some of the possible destinations may not be visible on the screen. I want to dynamically draw a clickable direction indicator (such as an arrow) that emanates from the user location and points to any off-screen destination. If there are multiple off-screen destinations, I'd probably want to scale the arrow lengths to indicate relative distances. If the user clicks on the arrow, they should be "teleported" to the off-screen location.
Any thoughts on how to best implement this? The only information I've found on overlays uses static files (Most overlays seem to be just .PNG files for markers; one example had a route that was drawn from an XML file). I'd need to calculate the arrow based on direction
to the destination (direction the arrow points) and the relative distance to that location (arrow length), so the overlay is something I'd have to come up with at run time.
I think the main challenge is drawing the clickable arrows, but another question that comes to mind is, should I search using the Google Maps API, or is this job more suited to the Google Places API?
Thanks!
I guess we should put the teleportation on hold until the problem of a dynamically-drawn, clickable overlay is solved then!
A dynamically-drawn, clickable overlay is merely a subclass of Overlay. You will override one or both of the draw() methods to render your arrows using the Canvas 2D drawing API. You will override onTap() to be notified of taps on the map, to see if they tapped on an arrow. You add the overlay to the MapView via addOverlays().add().
Most overlays seem to be just .PNG files for markers
Those are usually ItemizedOverlay classes. That's much simpler to implement, particularly if you are one of those developers (like me) who is all thumbs when it comes to Canvas. However, you cannot achieve what you want with an ItemizedOverlay, in all likelihood.
I'd need to calculate the arrow based on direction to the destination (direction the arrow points) and the relative distance to that location (arrow length), so the overlay is something I'd have to come up with at run time.
Correct. You can use a Projection to help convert between pixel space and geo-space (latitude and longitude), if needed.
Note that this all assumes you are trying to use MapActivity and MapView. You are also welcome to use WebView or a plain browser to bring up your own JavaScript-based maps, if you prefer.
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.