Chris Rockwell

Joined

4,280 Experience
42 Lessons Completed
0 Questions Solved

Activity

Posted in Upload in webview

Hi Rafael - this could be any of a million different things, but the most obvious one is permissions. Does the iOS app ask the user for permission to access the camera roll? If it doesn't, then that's at least part of the problem. The app needs to get the User's permission before it can pull up the saved photos from the phone and/or access the device camera.

Based on the suggestion from Tabish above, I started playing around with a couple of different ideas. And the solution that seems to be working is to add a second 'addDomListener' statement into my js file. I am using the jQuery-turbolinks gem, so the file looks like -

$(document).ready(function()){

 function initMap(){

  .....google maps code here

 }

 google.maps.event.addDomListener(window, 'load', initMap);

 google.maps.event.addDomListener(window, 'page:load', initMap);

}

And I'm actually fairly sure the 2 statements can be combined into one, just don't have the desire to spend anymore time on this currently!!!

Hi Tabish - Thanks for the suggestion! Unfortunately that did not take care of the problem. I'm trying a few other things now and will post an update if I can get this figured out.

With the number of sites using googlemaps, it doesn't seem like this should be all that difficult!

Hey Chris - been struggling with this off and on for a bit now. Just trying to add basic google maps using the javascript API (not the gems) to a rails 4.2 app and am having all of the various issues that seem to pop up on stack overflow. The google API itself is really well documented and pretty straightforward, but I can't seem to find a clear consensus about how to make this work with turbo links.

( If I turn off turbo links, everything works fine. But turning off turbo links causes some unwelcome behavior when running as a 'native-ish' app in iOS/safari.)

So, with turbo links on, there are a couple of errors - the first of which is the map not displaying at all without a full page reload, and the second is a javascript error about loading the googlemaps API multiple times.

So, my questions are -

  1. Where do you recommend placing the googlemaps API script tag? (In which file, and in which position in that file). I'm currently including it with a javascript_include_tag at the bottom of the view where the map is displayed.

  2. How should my jQuery code for initializing the gmaps and setting the parameters be included? I'm currently using the jQuery.turbolinks gem and including my jQuery code for gmaps in a standard closure per the jQuery.turbolinks docs. (I think I added the jQuery.turbolinks gem to fix this problem in the first place - so I'm happy to remove it if it's not necessary)

And again, everything works if I turn the turbo links off, so it is seems like it has to be something with either the load order or the timing of the event listener.

any suggestions appreciated!...chris

logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2020 GoRails, LLC. All rights reserved.