3 locations shows 1

  • Replies:2
  • OpenNot stickiedUnanswered
  • Forum posts: 1

Sep 29, 2014 2:09:06 AM via Website

I'm trying to make a 3 locations markers on the google map (maybe more) but the problem is it shows only the first thing that I put (Place 1) .. how can I make the button shows me the 3 markers?

zero.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {

            String DESTINATION_LOCATION1 = "Place 1";
            String latit1 = "40.054958";
            String longit1 = "18.420317";
            String DESTINATION_LOCATION2 = "Place 2";
            String latit2 = "39.735692";
            String longit2 = "19.689583";
            String DESTINATION_LOCATION3 = "Place 3";
            String latit3 = "39.567350";
            String longit3 = "19.854964";

            Intent intent1 = new Intent(android.content.Intent.ACTION_VIEW,
                    Uri.parse("geo:<" + latit1 + ">,<" + longit1 + ">?q=<"
                            + latit1 + ">,<" + longit1 + ">("
                            + DESTINATION_LOCATION1 + ")"));
            startActivity(intent1);
        }       
    });

It gives a warning under DESTINATION_LOCATION2, latit2, longit2, DESTINATION_LOCATION3, latit3 and longit3 p.s. no GPS

— modified on Sep 29, 2014 2:10:02 AM

  • Forum posts: 118

Nov 7, 2014 11:54:00 AM via Website

Are you using Google Maps Api v2 Android? If so, why don't you make a model that only uses the LatLng class and just a string. It'd look like something like that this:

public MyMarker {
   private LatLng coordinates;
   private String name;

   public MyMarker(String n, LatLng c) {
         this.coordinates = c; this.name = n;
   }

   public String getName() { return this.name; }
   public LatLng getCoordinates() { return this.coordinates; }
}

Usage of this in your onSetOnClickListener would:

MyMarker markerOne = new MyMarker("Place 1", new LatLng(40.054958, 18.420317));

Add all those markers in an arraylist or any other list, put into a bundle and pass the list through in the intent to another activity. For-loop the markers in the second activity and add those variables in the map markers.

  • Forum posts: 33

Apr 24, 2015 11:28:24 AM via Website

In first phase review your code, I am confident that it should be work.Please check another parameters like back end and server side.