-3

Forgive me for being new to android app building.

My plan is to build an app that would take a city and open a new activity for it. The problem is I really don't know how to go about that. My plan would be very similar to how the app yik yak does it where you go put a marker in a certain area and it brings you to the activity for that location. I believe yik yak only shows the ones that are close to you but my plan was to take you to an activity for that location. Is that possible to do it that way or should I take yik yak's route on it and only show things that are within a certain radius of you?

Where can I get started on learning how to do that?

gunSC
  • 13
  • 4

2 Answers2

0

First, you need to choose a provider for your maps.

I would say google map is a good start as you suggested in the tag, but beware, it might not be available on some Chinese devices without play services. You can follow the documentation here for a quick start https://developers.google.com/maps/documentation/android/

Regarding the number of pins you want to put on your map, I see no problem to display a lot of them, you just have to group markers as the user zooms out, so you don't have 10 pins overlapping themselves. So if in a quite zoomed state, the user clicks a group of markers, you can display a dialog to choose the city. If the user zooms in a lot and clicks a particular pin, then you can start an activity.

Your main concern is listening for a zoom level change, like that:

mMap.setOnCameraChangeListener(new OnCameraChangeListener() { 

    private float currentZoom = -1;

    @Override 
    public void onCameraChange(CameraPosition pos) {
        if (pos.zoom != currentZoom){
            currentZoom = pos.zoom;
            // do you action here 
        } 
    } 
}); 

Credits: https://stackoverflow.com/a/15046761/689710

Then, you can create a Map of Lists, the keys of the map will be the a custom lat / long object. Let's call it Pin. Pin provides it a custom isCloseTo method (taking a zoomlevel in params, and an other Pin object).

For each city you want to add on the map
    For each key in the map
        If the Pin object of your city isCloseTo the Pin key of the map
            Add it to the list for that key
        Else
            Add a new Map entry with you city Pin as key and a list with your city as value

You Pin.isCloseTo method will be somehow similar to that:

https://stackoverflow.com/a/18170277/689710

Returning true or false according to "dist" return and your zoom level.

When you processed all your cities, you can browse the map and create a marker for each Pin key.

In a zoomed in state, you will have a Map with lists containing only one item, but i don't think it's much a problem.

Community
  • 1
  • 1
Mostrapotski
  • 425
  • 3
  • 11
0

You know yik yak is not starting a new activity when the place on the map is clicked. It rather updates the data underneath it when a new place is clicked. I think what you mean is you want to refresh/change the data displayed when a new city on google maps is clicked?

user2132226
  • 85
  • 1
  • 1