I am facing a problem while i am developing an application Using Google maps SDK.
I am creating dynamically some markers on the map, but these markers are quite big (using custom marker image and label above them).
But when i try to tap on a specific marker many times it selects the very next to it.
The accuracy of the click is not perfect and more over some times i need to click twice in order to get the click event get fired.
Making a google search i found that there are some issues with google maps sdk markers.
Is the issue being caused because of the size of the markers?
You can you marker options like this.
MarkerOptions lMarkerOpt = new MarkerOptions()
.title("Title")
.draggable(true)
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE))
.position(YourLatLng)
.snippet("Title");
It will use default marker with whatever color you want.
Related
i am creating a app which offers a service for place to register and store general details and their location then I'd like to retrieve these places locations on the Android app ,based on the user's location, So that when a app user open the app, the registered place near that user in a 5 mile radius is listed or shows on map
Kindly provide the useful solutions or links related to such scenario.
thanks
You can use markers to add locations in google maps. https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker
Google lists everything here. They also have a sample app on Github here. I'd suggest starting a sample map activity project in Android Studio, it should help you understand the basics of implementing a Google Map in your project.
GoogleMap map = ... // get a map.
// Add a marker at San Francisco.
Marker marker = map.addMarker(new MarkerOptions()
.position(new LatLng(37.7750, 122.4183))
.title("San Francisco")
.snippet("Population: 776733"));
I'm developing an android application in which I've used Google Map v2 API.
I've placed one marker on the map, now I want to set its "OnLongClickListener".
As I can see from Eclipse there are only two listeners available for marker:
googleMap.setOnMarkerClickListener(listener);
googleMap.setOnMarkerDragListener(listener);
Could anybody show me any easy way to handle marker's LongClick event??
I've gone through two solutions here:
Setting a LongClickListener on a map Marker
How to detect long click on GoogleMap marker
as both of the solutions you posted have shown - there is no long click event on markers in the maps api. the first link you posted had a solution that might be able to suit your needs but isn't perfect by any means
i would suggest going here to the gmaps issues page and browsing through the feature requests and adding one if it does not exist
After a while of googling I cannot find what I need, I see some libraries which look to do it but I have already implemented the system using androids default methods.
I set the markers like so:
theMap.addMarker(new MarkerOptions()
.position(new LatLng(lat, lon))
.title(title)
.icon(BitmapDescriptorFactory.fromResource(R.drawable.pin_map32))
.snippet(strap));
However I need a 'detail disclosure button' like on iOS (transitioning app from iOS to Android) and I can't seem to add a button to the marker - is it possible using androids system?
This cannot be done.
from the docs
Note: The info window that is drawn is not a live view. The view is rendered as an image (using View.draw(Canvas)) at the time it is returned. This means that any subsequent changes to the view will not be reflected by the info window on the map. To update the info window later (e.g., after an image has loaded), call showInfoWindow(). Furthermore, the info window will not respect any of the interactivity typical for a normal view such as touch or gesture events. However you can listen to a generic click event on the whole info window as described in the section below.
in other words you cannot put a button in the infowindow and be able to use it. You will need to use a dialog of sorts if you want to do something like that
There is always some way.
A nice hack can be found here: https://stackoverflow.com/a/15040761/2183804
I haven't tested it myself, but from the comments there (and the amount of upvotes) we can deduce it works well.
You can track clicks only on Marker. If you want a button on marker - click on marker & show a dialog with buttons.
I am building an Android application that shows the user his/her current location (using MyLocationOverlay), and I am also using a LocationManager/LocationListener to get the user's location every 15 seconds, which is then used to query a web service and in return I plot points using an ItemizedOverlay.
This is all working with no problems.
Should I be using BOTH MyLocationOverlay as well as LocationManager/LocationListener, however? It seems redundant. What would you do? From what I can see, MyLocationOverlay uses the LocationManager in the background to constantly receive location updates, anyway.
Thanks!
The MyLocationOverlay does a little more such as adding the overlay to the map, showing the error radius and making it cool and blinky! There is nothing wrong with using it in conjunction with getting your own updates. In my app I decided not to use it because I wanted to change the way that it looked so that it was more like what you see in the Maps app where the MyLocationOverlay is an arrow that shows what direction you're facing. It's really a matter of preference.
I am looking for some help....
Firstly I have a database server side with a numerous amount of locations(longs +lats)
Now there are upto a 1000 for one city alone. At the moment, my android device all the information at once. I then create 1000 itemized overlays and add them to the map view.
This in turn makes my emulator and phone run slow.
One idea I had was to zoom in on a location and then download and place a subset of the overlays on the map view.
Trouble I have with this
1. When I scroll on the map I don't know what event to register a listener to.
2. When the user zooms out I will still create the large number of itemised overlays.
My question to you guys is,
How could I overcome these problems? Or how would you go about doing this?
The solution Would be something similar to how google maps works. U c a not so detailed map when u zoom out, but when u zoom in it shows you a detailed map that reloads as you move around
I then create 1000 itemized overlays and add them to the map view.
Ummmm... please tell me that this is a typo, and you meant "1000 OverlayItems", not "1000 ItemizedOverlays".
1000 OverlayItems might be bad enough -- ItemizedOverlay isn't really designed for that many points.
When I scroll on the map I don't know what event to register a listener to.
I don't think there is a straightforward solution here. I think others have kinda reverse-engineered the touch events and are listening on those. See Android Maps get Scroll Event for more.
When the user zooms out I will still create the large number of itemised overlays.
Use a prioritization scheme. What you see with Google Maps is that only the top N items are shown, where "top" is based on some sort of priority mechanism.