In Android, open google maps to show multiple markers












0














I have several markers with descriptions in JSON format (but I could use another). How would I open this in google maps (v2) from my android application?



Example of the data:



[
{
"name":"Ice Cream Daydream",
"description":"OTR;33 E 12th St,</div>Cincinnati, OH 45202<br><img src=",
"lon":-84.513634,
"lat":39.108456,
"tour":"otr",
"image":""
},
{
"name":"Into the Renaissance",
"description":"OTR;1519 Vine St,</div>Cincinnati, OH 45202<br><img src=",
"lon":-84.516068,
"lat":39.11235,
"tour":"otr",
"image":""
},
{
"name":"Know Theater Murals",
"description":"OTR; </div>1120 Jackson St,Cincinnati, OH 45202<br><img src=",
"lon":-84.513672,
"lat":39.108154,
"tour":"otr",
"image":""
}
]









share|improve this question
























  • For google maps...please visit:developers.google.com/maps/documentation/android/intro for adding markers: developers.google.com/maps/documentation/android/marker
    – Atish Agrawal
    Apr 9 '14 at 0:25










  • Will those help with adding multiple in one view?
    – LisaH
    Apr 9 '14 at 0:49










  • multiple markers on one google map is possible.
    – Atish Agrawal
    Apr 9 '14 at 3:19










  • Just hard to find an example. I can parse the JSON, but how to get that to the map is where I am wondering
    – LisaH
    Apr 9 '14 at 15:32










  • send me your code. I'll have a look
    – Atish Agrawal
    Apr 9 '14 at 16:15
















0














I have several markers with descriptions in JSON format (but I could use another). How would I open this in google maps (v2) from my android application?



Example of the data:



[
{
"name":"Ice Cream Daydream",
"description":"OTR;33 E 12th St,</div>Cincinnati, OH 45202<br><img src=",
"lon":-84.513634,
"lat":39.108456,
"tour":"otr",
"image":""
},
{
"name":"Into the Renaissance",
"description":"OTR;1519 Vine St,</div>Cincinnati, OH 45202<br><img src=",
"lon":-84.516068,
"lat":39.11235,
"tour":"otr",
"image":""
},
{
"name":"Know Theater Murals",
"description":"OTR; </div>1120 Jackson St,Cincinnati, OH 45202<br><img src=",
"lon":-84.513672,
"lat":39.108154,
"tour":"otr",
"image":""
}
]









share|improve this question
























  • For google maps...please visit:developers.google.com/maps/documentation/android/intro for adding markers: developers.google.com/maps/documentation/android/marker
    – Atish Agrawal
    Apr 9 '14 at 0:25










  • Will those help with adding multiple in one view?
    – LisaH
    Apr 9 '14 at 0:49










  • multiple markers on one google map is possible.
    – Atish Agrawal
    Apr 9 '14 at 3:19










  • Just hard to find an example. I can parse the JSON, but how to get that to the map is where I am wondering
    – LisaH
    Apr 9 '14 at 15:32










  • send me your code. I'll have a look
    – Atish Agrawal
    Apr 9 '14 at 16:15














0












0








0







I have several markers with descriptions in JSON format (but I could use another). How would I open this in google maps (v2) from my android application?



Example of the data:



[
{
"name":"Ice Cream Daydream",
"description":"OTR;33 E 12th St,</div>Cincinnati, OH 45202<br><img src=",
"lon":-84.513634,
"lat":39.108456,
"tour":"otr",
"image":""
},
{
"name":"Into the Renaissance",
"description":"OTR;1519 Vine St,</div>Cincinnati, OH 45202<br><img src=",
"lon":-84.516068,
"lat":39.11235,
"tour":"otr",
"image":""
},
{
"name":"Know Theater Murals",
"description":"OTR; </div>1120 Jackson St,Cincinnati, OH 45202<br><img src=",
"lon":-84.513672,
"lat":39.108154,
"tour":"otr",
"image":""
}
]









share|improve this question















I have several markers with descriptions in JSON format (but I could use another). How would I open this in google maps (v2) from my android application?



Example of the data:



[
{
"name":"Ice Cream Daydream",
"description":"OTR;33 E 12th St,</div>Cincinnati, OH 45202<br><img src=",
"lon":-84.513634,
"lat":39.108456,
"tour":"otr",
"image":""
},
{
"name":"Into the Renaissance",
"description":"OTR;1519 Vine St,</div>Cincinnati, OH 45202<br><img src=",
"lon":-84.516068,
"lat":39.11235,
"tour":"otr",
"image":""
},
{
"name":"Know Theater Murals",
"description":"OTR; </div>1120 Jackson St,Cincinnati, OH 45202<br><img src=",
"lon":-84.513672,
"lat":39.108154,
"tour":"otr",
"image":""
}
]






android google-maps google-maps-markers






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 9 '14 at 0:40









a14m

4,58933554




4,58933554










asked Apr 9 '14 at 0:05









LisaH

5318




5318












  • For google maps...please visit:developers.google.com/maps/documentation/android/intro for adding markers: developers.google.com/maps/documentation/android/marker
    – Atish Agrawal
    Apr 9 '14 at 0:25










  • Will those help with adding multiple in one view?
    – LisaH
    Apr 9 '14 at 0:49










  • multiple markers on one google map is possible.
    – Atish Agrawal
    Apr 9 '14 at 3:19










  • Just hard to find an example. I can parse the JSON, but how to get that to the map is where I am wondering
    – LisaH
    Apr 9 '14 at 15:32










  • send me your code. I'll have a look
    – Atish Agrawal
    Apr 9 '14 at 16:15


















  • For google maps...please visit:developers.google.com/maps/documentation/android/intro for adding markers: developers.google.com/maps/documentation/android/marker
    – Atish Agrawal
    Apr 9 '14 at 0:25










  • Will those help with adding multiple in one view?
    – LisaH
    Apr 9 '14 at 0:49










  • multiple markers on one google map is possible.
    – Atish Agrawal
    Apr 9 '14 at 3:19










  • Just hard to find an example. I can parse the JSON, but how to get that to the map is where I am wondering
    – LisaH
    Apr 9 '14 at 15:32










  • send me your code. I'll have a look
    – Atish Agrawal
    Apr 9 '14 at 16:15
















For google maps...please visit:developers.google.com/maps/documentation/android/intro for adding markers: developers.google.com/maps/documentation/android/marker
– Atish Agrawal
Apr 9 '14 at 0:25




For google maps...please visit:developers.google.com/maps/documentation/android/intro for adding markers: developers.google.com/maps/documentation/android/marker
– Atish Agrawal
Apr 9 '14 at 0:25












Will those help with adding multiple in one view?
– LisaH
Apr 9 '14 at 0:49




Will those help with adding multiple in one view?
– LisaH
Apr 9 '14 at 0:49












multiple markers on one google map is possible.
– Atish Agrawal
Apr 9 '14 at 3:19




multiple markers on one google map is possible.
– Atish Agrawal
Apr 9 '14 at 3:19












Just hard to find an example. I can parse the JSON, but how to get that to the map is where I am wondering
– LisaH
Apr 9 '14 at 15:32




Just hard to find an example. I can parse the JSON, but how to get that to the map is where I am wondering
– LisaH
Apr 9 '14 at 15:32












send me your code. I'll have a look
– Atish Agrawal
Apr 9 '14 at 16:15




send me your code. I'll have a look
– Atish Agrawal
Apr 9 '14 at 16:15












1 Answer
1






active

oldest

votes


















0














In XML file



 <FrameLayout
android:id="@+id/mapContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content" />


In Java File



FrameLayout mapContainer = (FrameLayout) findViewById(R.id.mapContainer);
FragmentManager fm = getFragmentManager();
MapFragment mapFragment = MapFragment.newInstance();
fm.beginTransaction().replace(R.id.mapContainer, mapFragment).commit();

mapFragment.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap googleMap) {
GoogleMap mMap = googleMap;
mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
addMarks(mMap);
});
}


ADD Multiple Marker



 private void addMarks(GoogleMap googleMap) {
LatLngBounds.Builder builder = new LatLngBounds.Builder();
for (int i = 0; i < list.size(); i++) {
LatLng latLng = new LatLng(latitute, longitute);
builder.include(latLng);
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(latLng);
markerOptions.title(storeLocation);
}

}





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f22950495%2fin-android-open-google-maps-to-show-multiple-markers%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    In XML file



     <FrameLayout
    android:id="@+id/mapContainer"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />


    In Java File



    FrameLayout mapContainer = (FrameLayout) findViewById(R.id.mapContainer);
    FragmentManager fm = getFragmentManager();
    MapFragment mapFragment = MapFragment.newInstance();
    fm.beginTransaction().replace(R.id.mapContainer, mapFragment).commit();

    mapFragment.getMapAsync(new OnMapReadyCallback() {
    @Override
    public void onMapReady(GoogleMap googleMap) {
    GoogleMap mMap = googleMap;
    mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
    addMarks(mMap);
    });
    }


    ADD Multiple Marker



     private void addMarks(GoogleMap googleMap) {
    LatLngBounds.Builder builder = new LatLngBounds.Builder();
    for (int i = 0; i < list.size(); i++) {
    LatLng latLng = new LatLng(latitute, longitute);
    builder.include(latLng);
    MarkerOptions markerOptions = new MarkerOptions();
    markerOptions.position(latLng);
    markerOptions.title(storeLocation);
    }

    }





    share|improve this answer




























      0














      In XML file



       <FrameLayout
      android:id="@+id/mapContainer"
      android:layout_width="match_parent"
      android:layout_height="wrap_content" />


      In Java File



      FrameLayout mapContainer = (FrameLayout) findViewById(R.id.mapContainer);
      FragmentManager fm = getFragmentManager();
      MapFragment mapFragment = MapFragment.newInstance();
      fm.beginTransaction().replace(R.id.mapContainer, mapFragment).commit();

      mapFragment.getMapAsync(new OnMapReadyCallback() {
      @Override
      public void onMapReady(GoogleMap googleMap) {
      GoogleMap mMap = googleMap;
      mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
      addMarks(mMap);
      });
      }


      ADD Multiple Marker



       private void addMarks(GoogleMap googleMap) {
      LatLngBounds.Builder builder = new LatLngBounds.Builder();
      for (int i = 0; i < list.size(); i++) {
      LatLng latLng = new LatLng(latitute, longitute);
      builder.include(latLng);
      MarkerOptions markerOptions = new MarkerOptions();
      markerOptions.position(latLng);
      markerOptions.title(storeLocation);
      }

      }





      share|improve this answer


























        0












        0








        0






        In XML file



         <FrameLayout
        android:id="@+id/mapContainer"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />


        In Java File



        FrameLayout mapContainer = (FrameLayout) findViewById(R.id.mapContainer);
        FragmentManager fm = getFragmentManager();
        MapFragment mapFragment = MapFragment.newInstance();
        fm.beginTransaction().replace(R.id.mapContainer, mapFragment).commit();

        mapFragment.getMapAsync(new OnMapReadyCallback() {
        @Override
        public void onMapReady(GoogleMap googleMap) {
        GoogleMap mMap = googleMap;
        mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
        addMarks(mMap);
        });
        }


        ADD Multiple Marker



         private void addMarks(GoogleMap googleMap) {
        LatLngBounds.Builder builder = new LatLngBounds.Builder();
        for (int i = 0; i < list.size(); i++) {
        LatLng latLng = new LatLng(latitute, longitute);
        builder.include(latLng);
        MarkerOptions markerOptions = new MarkerOptions();
        markerOptions.position(latLng);
        markerOptions.title(storeLocation);
        }

        }





        share|improve this answer














        In XML file



         <FrameLayout
        android:id="@+id/mapContainer"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />


        In Java File



        FrameLayout mapContainer = (FrameLayout) findViewById(R.id.mapContainer);
        FragmentManager fm = getFragmentManager();
        MapFragment mapFragment = MapFragment.newInstance();
        fm.beginTransaction().replace(R.id.mapContainer, mapFragment).commit();

        mapFragment.getMapAsync(new OnMapReadyCallback() {
        @Override
        public void onMapReady(GoogleMap googleMap) {
        GoogleMap mMap = googleMap;
        mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
        addMarks(mMap);
        });
        }


        ADD Multiple Marker



         private void addMarks(GoogleMap googleMap) {
        LatLngBounds.Builder builder = new LatLngBounds.Builder();
        for (int i = 0; i < list.size(); i++) {
        LatLng latLng = new LatLng(latitute, longitute);
        builder.include(latLng);
        MarkerOptions markerOptions = new MarkerOptions();
        markerOptions.position(latLng);
        markerOptions.title(storeLocation);
        }

        }






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 20 at 6:39

























        answered Aug 29 '16 at 11:48









        Ramesh Kumar

        9541323




        9541323






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f22950495%2fin-android-open-google-maps-to-show-multiple-markers%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            If I really need a card on my start hand, how many mulligans make sense? [duplicate]

            Alcedinidae

            Can an atomic nucleus contain both particles and antiparticles? [duplicate]