Solved

Launch Google maps from Ionic with multiple markers

Posted on 2016-08-03
4
66 Views
Last Modified: 2016-08-24
We are using the following code to launch Google Maps (which are downloaded for offline access) from Ionic application.

var location = '33.917236,-118.012009';
 window.open('comgooglemaps://?q=' + location, '_system');

Open in new window


This launches Google Maps application on ios and sets the marker at the Longitude and Latitude that has been defined (even when the user is offline).

However, our requirement is to place multiple markers on the map. I have not been able to find a way to pass multiple longitudes and latitudes to the q parameter.

Any suggestions on how this requirement can be achieved?
0
Comment
Question by:ank5
  • 3
4 Comments
 
LVL 25

Accepted Solution

by:
dgrafx earned 500 total points (awarded by participants)
ID: 41742747
This should get you over the hump - you can add all your markers:

json = [
      {
      "mid": "123456",
      "title": "Cinemark Xd",
      "address": "6081 Center Dr #201, Los Angeles, CA 90045",
      "lat": "33.97803",
      "lng": "-118.39155"
      },
      {
      "mid": "654321",
      "title": "SCGC",
      "address": "8141 Gulana Ave, Playa Del Rey, CA 90293",
      "lat": "33.96128",
      "lng": "-118.43727"
      }
];
function initialize(json) {
      mapDiv = document.getElementById('gmap');
      mapOptions = {
            zoom: 12,
            minzoom: 5,
            mapTypeControl: true,
            zoomControl: true,
            scaleControl: true,
            streetViewControl: true,
            mapTypeId: google.maps.MapTypeId.ROADMAP            
      }
      
      map = new google.maps.Map(mapDiv, mapOptions);
      map.setCenter(new google.maps.LatLng(json[0].lat, json[0].lng));      
      
            google.maps.event.addListenerOnce(map, 'idle', function(){
                  $.each(json, function(key, data) {
                        //CALL YOUR CREATE MARKER FUNCTION HERE
                        //createMarker(map,data,key);
                  });            
            });
}
0
 
LVL 1

Author Comment

by:ank5
ID: 41744591
Thanks for sharing the example.

Will this launch the Google maps application on the device or can it only be used to display maps within the Ionic application?

We wanted to launch the Google maps application as user would not have internet access, so offline (downloaded) Google maps need to be used.
0
 
LVL 25

Expert Comment

by:dgrafx
ID: 41744623
I'm not sure - if all resources are available I see no reason why it wouldn't run offline
0
 
LVL 25

Expert Comment

by:dgrafx
ID: 41768440
That should be it on this question so let's wrap it up
Good luck on your project
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
CSS Position not returning 2 46
CSS change width browser switches to mobile view 2 48
Mobile app idea 6 32
Javascript to allow login/password authorization 4 27
Read about why website design really matters in today's demanding market.
By this time the large percentage of day-to-day transactions have shifted to mobile banking; here are some overriding areas QAs must investigate while testing mobile banking apps.  
This Micro Tutorial demonstrates in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
By using UNIQUE function in Google Sheets, you can get around removing duplicates like in Microsoft Excel.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now