Page 442 of 615 FirstFirst ... 342392432440441442443444452492542 ... LastLast
Results 8,821 to 8,840 of 12287

Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.


Thread: UniAW7

  1. #8821
    Default How to add location info from Google
    How to add location info from Google...

    Hope this helps. Please note that path and filenames may be different in your widget. Also please note that the way this is formatted might give you different location results (ie: township instead of county, etc.)

    1) Make sure you have a myLocation.txt file in your documents folder. The WidgetWeather2 tweak will create it for you by turning this switch on...

    -img_0520.png
    -img_0519.png

    2) Find your favorite WW widget and open the scripts/main.js file. Add the code in red below to the top of the "dealWithWeather" function (**please see picture at bottom of post. The code in blue in this box isn't displaying properly)...

    Code:
    function dealWithWeather(obj) {
    	
    var url2 = "file:///private/var/mobile/Documents/myLocation" + ".txt";
    jQuery.get(url2, function(appdata){
    		var substr = appdata.split('\n');
    		var templatitude=substr[0].split('=');
    		var templongitude=substr[1].split('=');
    		var latitude = $.trim(templatitude[1]);
    		var longitude = $.trim(templongitude[1]);
    		obj.coords = latitude + "," + longitude;
    				
    	var Gurl = "http://maps.googleapis.com/maps/api/geocode/xml?latlng=" + obj.coords + "&sensor=false";
    	jQuery.get(Gurl, function(data) {
    		obj.type = [];
    		obj.longname = [];
    		
    		var s=0;
    		$(data).find('address_component').each( function() {
    		obj.longname[s] = $(this).find('long_name').text();
    		obj.type[s] = $(this).find('type').text();    
    		s++;
    		
    	});
    
    	for (i=0; i < obj.type.length; i++) {   
        if (obj.type[i].indexOf('street_number') != -1) { var stnumber = obj.longname[i]; break; } else{ var stnumber = " "}}
        
    	for (i=0; i < obj.type.length; i++) {   
        if (obj.type[i].indexOf('route') != -1) { var address = obj.longname[i]; break; }else{ var address = " "} }
    
    	for (i=0; i < obj.type.length; i++) {
        if ((obj.type[i].match('locality') ) && (!obj.type[i].match('sublocality') )) { var city = obj.longname[i]; break; }else{ var city = " "} }
    
    	for (i=0; i < obj.type.length; i++) {
    	if (obj.type[i].indexOf('administrative_area_level_2') > -1) { var county = obj.longname[i]; break; } }
    	 
    	for (i=0; i < obj.type.length; i++) {
    	if (obj.type[i].indexOf('administrative_area_level_3') > -1) { var neighborhood = obj.longname[i]; break; } }
    
    	document.getElementById("Gaddress").innerHTML = stnumber + " " + address;
    	document.getElementById("Gcity").innerHTML = city;
    	document.getElementById("Gneighborhood").innerHTML = neighborhood;
    	document.getElementById("Gcounty").innerHTML = county;
    
    	});
    
    });
    3) Open the css/style.css file. Find the "city" element. Likely something similar to...

    Code:
    #city {
    	position:absolute;
    	top:73%;
    	width:100%;
    	text-align:center;
    	font-family: Plane; 
    	font-size:4.5vw;
    	text-transform:lowercase;
    	color: #BCC6CC;
    	display:none;
    	text-shadow: 0px 2px 2px #000;
    }
    Copy the entire section and paste it directly underneath but rename the second instance to "Gcity". So...

    Code:
    #city {
    	position:absolute;
    	top:73%;
    	width:100%;
    	text-align:center;
    	font-family: Plane; 
    	font-size:4.5vw;
    	text-transform:lowercase;
    	color: #BCC6CC;
    	display:none;
    	text-shadow: 0px 2px 2px #000;
    }
    
    #Gcity {
    	position:absolute;
    	top:73%;
    	width:100%;
    	text-align:center;
    	font-family: Plane; 
    	font-size:4.5vw;
    	text-transform:lowercase;
    	color: #BCC6CC;
    	text-shadow: 0px 2px 2px #000;
    }
    Add the "Display:none;" to the first instance (see red above).

    4) Do the same with the "address", "neighborhood" and "county" elements if you have them. Remember, case sensitive...

    Code:
    #address{
    	position:absolute; 
    	top:43%;
    	width: 100%;
    	text-align:center; 
    	z-index:90;
    	display:none;
    	font-family: Plane;
    	font-weight: normal; 
    	text-transform:lowercase;
    	font-size:3vw;
    	color: #BCC6CC;
    	text-shadow: 0px 2px 2px #000;
    }
    
    #Gaddress{
    	position:absolute; 
    	top:43%;
    	width: 100%;
    	text-align:center; 
    	z-index:90;
    	font-family: Plane;
    	font-weight: normal; 
    	text-transform:lowercase;
    	font-size:3vw;
    	color: #BCC6CC;
    	text-shadow: 0px 2px 2px #000;
    }
    
    #neighborhood {
    	position:absolute;
    	top:76.5%;
    	width:100%;
    	display:none;
    	text-align:center;
    	font-family: Plane; 
    	font-size:4.5vw;
    	text-transform:lowercase;
    	color: #BCC6CC;
    	text-shadow: 0px 2px 2px #000;
    }
    
    #Gneighborhood {
    	position:absolute;
    	top:76.5%;
    	width:100%;
    	text-align:center;
    	font-family: Plane; 
    	font-size:4.5vw;
    	text-transform:lowercase;
    	color: #BCC6CC;
    	text-shadow: 0px 2px 2px #000;
    }
    
    #county {
    	position:absolute;
    	top:80%;
    	width:100%;
    	text-align:center;
    	font-family: Plane; 
    	font-size:4.5vw;
    	text-transform:lowercase;
    	color: #BCC6CC;
    	display:none;
    	text-shadow: 0px 2px 2px #000;
    }
    
    #Gcounty {
    	position:absolute;
    	top:80%;
    	width:100%;
    	text-align:center;
    	font-family: Plane; 
    	font-size:4.5vw;
    	text-transform:lowercase;
    	color: #BCC6CC;
    	text-shadow: 0px 2px 2px #000;
    }
    5) Open the Widget.html file or LockBackground.html file. Find the "city" div and add a "Gcity" div above it. So....

    Code:
    <div id="Gcity"></div>
    <div id="city"></div>
    Same with neighborhood, address and county...

    Code:
    <div id="Gneighborhood"></div>
    <div id="neighborhood"></div>
    Code:
    <div id="Gaddress"></div>
    <div id="address"></div>
    Code:
    <div id="Gcounty"></div>
    <div id="county"></div>
    That's it! Now you should have city, neighborhood, county and address back in your widget, displaying exactly how they were before (ie: same position, size, font, etc.) I'm happy to try and answer any questions. Good luck!

    EDIT: Here's a picture of what the code in main.js should look like. As mentioned, for some reason it's not displaying properly above....

    -new-1.png

    Lastly, I would like to thank Grant for this workaround for location information. All the code above is derived from his widget.

  2. The Following 21 Users Say Thank You to Marty McFly For This Useful Post:

    #m37h{ (2016-01-22), adioph (2016-01-22), chevymusclecar (2016-01-25), dubailive (2016-01-22), Irish_Man (2016-01-22), jm26200 (2016-01-23), JohnnyBlueJ (2016-01-23), King_O_Hill (2016-01-22), kristatos (2016-01-22), lostinthemes (2016-01-29), Mary48336 (2016-01-22), Max_Pa1n (2016-01-24), Mike2130 (2016-01-22), NewD (2016-01-22), nik1975 (2016-01-22), ottozuts (2016-01-22), schalker44 (2016-01-22), Simon (2016-01-23), Sital (2016-01-22), Splatty79 (2016-01-22), VOLTAGExDT (2016-01-22)

  3. #8822
    Code Dependent NewD's Avatar
    Join Date
    Jan 2012
    Location
    Northeast US
    Posts
    5,733
    Thanks
    8,351
    Thanked 16,486 Times in 7,705 Posts

    Quote Originally Posted by rasputin007 View Post
    Yes, that was MYO5, but MYO6 is a bit different. I am using it for about 6 month now.
    Let's say I go from home to town A for some shopping, if I open the LS it says "Town A" with the latest weather info. If it says "Village B", which is on the way to Town A, then that happened because it was an automated update (GPS and weather) interval. Which still is not much of a problem, one tap on the touch function and GPS location and weather have been updated and it will say "Town A'.
    I have WW2 installed, but disabled, but I also do not use the stock weather app either as WeatherUnderground app is much better.
    It works for me, otherwise I would not use it. I am happy with it. But have to work on version 7 now that I do no longer need javascripts for sun/moon rise and set times as both are now in the response xml file.
    Well then I'd love to test again, Ras, and see if I can make it work for my purposes.. I'll contact you privately. And thanks for always pushing the envelope!!

  4. #8823
    Code Dependent NewD's Avatar
    Join Date
    Jan 2012
    Location
    Northeast US
    Posts
    5,733
    Thanks
    8,351
    Thanked 16,486 Times in 7,705 Posts

    Quote Originally Posted by Marty McFly View Post
    How to add location info from Google...

    Hope this helps. Please note that path and filenames may be different in your widget.

    That's it! Now you should have city and address back in your widget, displaying exactly how they were before (ie: same position, size, font, etc.) I'm happy to try and answer any questions. Good luck!
    GREAT, Marty!!! Glad that Google call code I posted is being put to good use!! That will get us up and running in the short term.

    Though sometimes people are going to see an 'establishment' or 'point of interest' in the Gaddress position and a street address in the Gcity position because of inconsistencies in the way Google reports data to that formatted_address[0] field in the 'quick and dirty' code call you're using there. So I just emailed you the more precise code that will make sure only a city will ever appear in Gcity.. and only a street address will appear in Gaddress.

    But great tutorial as always!!! You and Ian always NAIL tutorials!!!!

    EDITED: Marty.. Something happened in your cut and paste in the first code tag where you get the data from myLocation.txt.. A ')' is missing.. and a a variable starts on the line before it should.. Edit your post, please.

    This line:
    Code:
    var substr = appdata.split('\n		var templatitude=substr[0].split('=');
    Should be two lines of code.. like this:
    Code:
    var substr = appdata.split("\n");
    
    var templatitude=substr[0].split('=');
    Last edited by NewD; 2016-01-22 at 05:04 PM.

  5. The Following User Says Thank You to NewD For This Useful Post:

    dubailive (2016-01-22)

  6. #8824
    thanks. does it require google maps to work? my widget doesn't show after adding the code. :-(

  7. #8825
    @Marty fabulous just fabulous,thank you do you know if this can work maybe with the code in main.js?
    document.getElementById("Gneigborhood").innerHTML = Gneighborhood;

    i know in what city i am,but having trouble with neighborhood

  8. The Following User Says Thank You to #m37h{ For This Useful Post:

    Marty McFly (2016-01-22)

  9. #8826
    Code Dependent NewD's Avatar
    Join Date
    Jan 2012
    Location
    Northeast US
    Posts
    5,733
    Thanks
    8,351
    Thanked 16,486 Times in 7,705 Posts

    Quote Originally Posted by adioph View Post
    thanks. does it require google maps to work? my widget doesn't show after adding the code. :-(
    Take a look at my post #8823.. Sometimes when you cut and paste on the forum here things get messed up in code tags. Marty's js code has an error in it.. Look at the correction in my post #8823.. That should get it to work for you.

  10. The Following User Says Thank You to NewD For This Useful Post:

    adioph (2016-01-22)

  11. #8827
    Code Dependent NewD's Avatar
    Join Date
    Jan 2012
    Location
    Northeast US
    Posts
    5,733
    Thanks
    8,351
    Thanked 16,486 Times in 7,705 Posts

    Default UniAW7
    Quote Originally Posted by #m37h{ View Post
    @Marty fabulous just fabulous,thank you do you know if this can work maybe with the code in main.js?
    document.getElementById("Gneigborhood").innerHTML = Gneighborhood;

    i know in what city i am,but having trouble with neighborhood
    The code Marty's working with right now will only get you City and Street address, Meth.. Not neighborhood. I just gave Marty some more code tonight that will allow him to extract a WHOLE lot more out of the Google feed.. Marty will need to take it from my raw form and adapt it to our widgets. That's why he's called "The Formulator"..
    Last edited by NewD; 2016-01-22 at 03:37 PM.

  12. The Following 4 Users Say Thank You to NewD For This Useful Post:

    #m37h{ (2016-01-22), Boots (2016-01-22), kristatos (2016-01-22), Marty McFly (2016-01-22)

  13. #8828
    Code Dependent NewD's Avatar
    Join Date
    Jan 2012
    Location
    Northeast US
    Posts
    5,733
    Thanks
    8,351
    Thanked 16,486 Times in 7,705 Posts

    Default UniAW7
    ---Removed by request of UniAW7 team---
    Last edited by NewD; 2016-01-22 at 02:53 PM.

  14. The Following 4 Users Say Thank You to NewD For This Useful Post:

    #m37h{ (2016-01-22), dubailive (2016-01-22), kristatos (2016-01-22), Marty McFly (2016-01-22)

  15. #8829
    so the mylocation.txt just became useful for me againthank you guys

  16. The Following 3 Users Say Thank You to #m37h{ For This Useful Post:

    dubailive (2016-01-22), kristatos (2016-01-22), Marty McFly (2016-01-22)

  17. #8830
    where can I find Widget Weather 2, ie in which path

  18. The Following User Says Thank You to schalker44 For This Useful Post:

    dubailive (2016-01-22)

  19. #8831
    Quote Originally Posted by #m37h{ View Post
    @Marty fabulous just fabulous,thank you do you know if this can work maybe with the code in main.js?
    document.getElementById("Gneigborhood").innerHTML = Gneighborhood;

    i know in what city i am,but having trouble with neighborhood
    No Neighborhood with Google


    EDIT: My mistake. We can get neighborhood with Google. It's just not there for as many places as the Yahoo feed. Thank you for the info Grant.

  20. The Following 3 Users Say Thank You to Marty McFly For This Useful Post:

    #m37h{ (2016-01-22), <Ian Nicoll/> (2016-01-22), Irish_Man (2016-01-22)

  21. #8832
    There is a pretty good chance yahoo place finder will be back up... Right?

  22. #8833
    Quote Originally Posted by laMe View Post
    There is a pretty good chance yahoo place finder will be back up... Right?
    Fingers crossed for sure but it's possible that it's gone for good.

  23. The Following 2 Users Say Thank You to Marty McFly For This Useful Post:

    #m37h{ (2016-01-22), Irish_Man (2016-01-22)

  24. #8834

  25. The Following 6 Users Say Thank You to Marty McFly For This Useful Post:

    #m37h{ (2016-01-22), <Ian Nicoll/> (2016-01-22), Irish_Man (2016-01-22), King_O_Hill (2016-01-22), kristatos (2016-01-22), NewD (2016-01-22)

  26. #8835
    Quote Originally Posted by Marty McFly View Post
    Fingers crossed for sure but it's possible that it's gone for good.
    Marty, can u do me a favour please (or anyone who can do it quickly), please check your xml file & confirm you have some values for <longitude>124.75</longitude> and <latitude>10.16</latitude>. Thanks.
    Last edited by <Ian Nicoll/>; 2016-01-22 at 02:44 PM.

  27. The Following 3 Users Say Thank You to <Ian Nicoll/> For This Useful Post:

    Irish_Man (2016-01-23), King_O_Hill (2016-01-22), Marty McFly (2016-01-22)

  28. #8836
    Quote Originally Posted by ;7347375
    Marty, can u do me a favour please, please check your xml file & confirm you have values for <longitude>124.75</longitude> and <latitude>10.16</latitude>. Thanks.
    -imageuploadedbymodmyi1453470061.634877.jpg

    I sure do pal. Truncated to only 1 and 2 decimal points as you can see but yep, it's there. So I guess I could change my tutorial to use the widgetweather xml instead of the myLocation.txt file? What do you think sir?

  29. The Following 4 Users Say Thank You to Marty McFly For This Useful Post:

    <Ian Nicoll/> (2016-01-22), Irish_Man (2016-01-23), King_O_Hill (2016-01-22), NewD (2016-01-22)

  30. #8837
    I'm using it in UniAW7.1 like this (the code will only run if Yahoo API is down).
    Code:
    // Use Google for City Name only if Yahoo API is down
        if (obj.city == "TBD") {
            document.getElementById("city").style.display = 'none';
            document.getElementById("address").style.display = 'none';
    				
            var googleURL = "http://maps.googleapis.com/maps/api/geocode/xml?latlng=" + obj.latitude  + "," + obj.longitude + "&sensor=false";
            jQuery.get(googleURL, function(data) {
                obj.add = [];
                var t=0;
                $(data).find('result').each( function() {
                    obj.add[t] = $(this).find('formatted_address').text();
                    t++;
                });
            Gaddress = obj.add[0].split(",")[0].replace(/Pike/g,"Pk").replace(/Road/g,"Rd");
            Gcity = obj.add[0].split(",")[1].replace(/Pike/g,"Pk").replace(/Road/g,"Rd");
            document.getElementById("Gaddress").innerHTML = Gaddress;
            document.getElementById("Gcity").innerHTML = Gcity;
            });
    }
    As for the css, just duplicate #city & #address, re-name the duplicates to #Gcity & #Gaddress (no need to add the "display: none".
    Last edited by <Ian Nicoll/>; 2016-01-22 at 03:30 PM.

  31. The Following 7 Users Say Thank You to <Ian Nicoll/> For This Useful Post:

    #m37h{ (2016-01-22), Irish_Man (2016-01-23), jm26200 (2016-01-23), King_O_Hill (2016-01-22), Marty McFly (2016-01-22), NewD (2016-01-22), wrussell1989 (2016-01-23)

  32. #8838
    Code Dependent NewD's Avatar
    Join Date
    Jan 2012
    Location
    Northeast US
    Posts
    5,733
    Thanks
    8,351
    Thanked 16,486 Times in 7,705 Posts

    Quote Originally Posted by Marty McFly View Post
    Grant. Your post (#8828) is very much appreciated but I think it should be removed. It's not a tutorial. It's just "code diarrhea" that no one will have any idea what to do with. I understand that you mainly posted it for Ian and I. That being the case, let's remove it from the main thread to keep the confusion to a minimum. I will take a good look at it and then adjust my tutorial if I think it's warranted. Just my 2 cents.
    Understood.. Whatever's best for the community.

  33. The Following 2 Users Say Thank You to NewD For This Useful Post:

    Irish_Man (2016-01-23), Marty McFly (2016-01-22)

  34. #8839
    Quote Originally Posted by <Ian Nicoll/> View Post
    I'm using it in UniAW7.1 like this (the code will only run if Yahoo API is down).
    Code:
    // Use Google for City Name only if Yahoo API is down
        if (obj.city == "TBD") {
            document.getElementById("city").style.display = 'none';
            document.getElementById("address").style.display = 'none';
    				
            var googleURL = "http://maps.googleapis.com/maps/api/geocode/xml?latlng=" + obj.latitude  + "," + obj.longitude + "&sensor=false";
            jQuery.get(googleURL, function(data) {
                obj.add = [];
                var t=0;
                $(data).find('result').each( function() {
                    obj.add[t] = $(this).find('formatted_address').text();
                    t++;
                });
            Gaddress = obj.add[0].split(",")[0].replace(/Pike/g,"Pk").replace(/Road/g,"Rd");
            Gcity = obj.add[0].split(",")[1].replace(/Pike/g,"Pk").replace(/Road/g,"Rd");
            document.getElementById("Gaddress").innerHTML = Gaddress;
            document.getElementById("Gcity").innerHTML = Gcity;
            });
    }
    As for the css, just duplicate #city & #address, re-name the duplicates to #Gcity & #Gaddress (no need to add the "display: none".
    very nicely putted Ian,let us know m8,so i can start adding this to my widgets,thank you
    @Grant,thank you too for starting this

  35. The Following 3 Users Say Thank You to #m37h{ For This Useful Post:

    Irish_Man (2016-01-23), King_O_Hill (2016-01-22), NewD (2016-01-22)

  36. #8840
    Quote Originally Posted by #m37h{ View Post
    very nicely putted Ian,let us know m8,so i can start adding this to my widgets,thank you
    @Grant,thank you too for starting this
    I think this is the final code I will use, but for my area it's not very accurate it only shows main city name, I cannot get the neighbourhood (village) names to show, need more investigating for a better API, but I guess this is better than "TBD".

    In main.js add this to top of dealWithWeather function:
    Code:
    	// Use Google for City Name only if Yahoo API is down
    	if (obj.city == "TBD") {
    		document.getElementById("city").style.display = 'none';
    		document.getElementById("address").style.display = 'none';
    				
    		var googleURL = "http://maps.googleapis.com/maps/api/geocode/xml?latlng=" + obj.latitude  + "," + obj.longitude + "&sensor=false";
    		jQuery.get(googleURL, function(data) {
    			obj.add = [];
    			var t=0;
    			$(data).find('result').each( function() {
    				obj.add[t] = $(this).find('formatted_address').text();
    				t++;
    			});
    		Gaddress = obj.add[0].split(",")[0].replace(/Pike/g,"Pk").replace(/Road/g,"Rd");
    		Gcity = obj.add[0].split(",")[1].replace(/Pike/g,"Pk").replace(/Road/g,"Rd");
    		if (ShowAddress == true) {
    			document.getElementById("googleAddress").innerHTML = Gaddress;
    		}
    		document.getElementById("googleCity").innerHTML = Gcity;
    		});
    	}


    In style.css, duplicate #city AND #address, re-name the duplicates to #googleCity AND #googleAddress (case sensitive).

    In all html files add these div's inside the WeatherContainer div: <div id="googleCity"></div> AND <div id="googleAddress"></div>

    This uses the coordinates from the WW2 xml file so no need to turn on the MyLocation option.
    If Yahoo API starts working again this code will not run, it will automatically revert to the "normal" way.

    In the .js you don't need the ".replace(/Pike/g,"Pk").replace(/Road/g,"Rd")" for Gcity but I left it in anyway.
    You could change this line:
    Gcity = obj.add[0].split(",")[1].replace(/Pike/g,"Pk").replace(/Road/g,"Rd");
    To this:
    Gcity = obj.add[0].split(",")[1];
    Last edited by <Ian Nicoll/>; 2016-01-22 at 04:35 PM.

  37. The Following 7 Users Say Thank You to <Ian Nicoll/> For This Useful Post:

    #m37h{ (2016-01-22), jm26200 (2016-01-23), kristatos (2016-01-22), Marty McFly (2016-01-22), Mary48336 (2016-01-22), Mike2130 (2016-01-22), VOLTAGExDT (2016-01-22)

Page 442 of 615 FirstFirst ... 342392432440441442443444452492542 ... LastLast
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •