Jun 27, 2014

What is this???




google maps javascript api v3 using j-query



This post similar my post GEOLOCATION for Google Maps JavaScript V3

But this map using j-query.

First, prepare.

You will download library.

And unzip and copy  ui folder to you project.


Second, coding.

This is javascript for library.

  1. <!--jquery-ui-map-->
  2. <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
  3. <script type="text/javascript" src="ui/min/jquery.ui.map.full.min.js"></script>
  4. <script type="text/javascript" src="ui/jquery.ui.map.extensions.js"></script>

This is body

  1. <body>
  2.     <div data-role="page" id="page" data-fullscreen="true" class="map_style">
  3.     <div data-role="header" data-position="fixed">
  4.         <h1>map page</h1>
  5.     </div>
  6.     <div data-role="content" class="map_style">
  7.         <div id="map_canvas" class="map_style" >
  8.             </div> 
  9.     </div>
  10.     <div data-role="footer" data-position="fixed">
  11.         <div data-role="navbar">
  12.            <ul>
  13.            <li><a href="#" data-icon="search" id="currentpos">current location</a></li>
  14.            </ul>
  15.         </div>
  16.     </div>
  17.     </div>
  18. </body>

Add map_style class to page(line 2), content(line 6), map(line 7)

'Line 7' is map and 'line 13' is search button.

This is very important code.

This code Implement google map.

  1. <script type="text/javascript">
  2.     $(document).ready(function(e) {
  3.         var startpos=new google.maps.LatLng(37.309,126.875);
  4.         $("#map_canvas").gmap({
  5.             "center":startpos,
  6.         "zoom":16
  7.         });
  8.         $("#currentpos").click(function() {
  9.             $("#map_canvas").gmap("getCurrentPosition",function(position,status){
  10.             if(status=="OK"){
  11.                 var latlng=new google.maps.LatLng(
  12.                 position.coords.latitude,position.coords.longitude);
  13.                 var marker="http://www.google.com/intl/en_us/mapfiles/ms/icons/blue-dot.png";
  14.                 $("#map_canvas").gmap("get","map").panTo(latlng);
  15.                     $("#map_canvas").gmap("addMarker",{
  16.                     "position":latlng,
  17.                     "icon":marker
  18.                     }).click(function(){
  19.                         $("#map_canvas").gmap("openInfoWindow",{
  20.                         "content":"<b>current location</b> <img src='http://images.forbes.com/media/lists/companies/google_200x200.jpg' alt=''/>"},this);
  21.                         });
  22.             }else{
  23.                 alert("can't found location");
  24.             }
  25.         });
  26.     });
  27.     });//ready   
  28.    
  29. </script>
Look so complex but simple.

'Line 3' is init position for display map.

'Line 4~7' is display(position and zoom level)

'Line 8~26' is searching code.

'Line 8' is button click listener.

'Line 9' is check current position using sensor(gps or network)

I recommend using mobile.

'Line 10~21' is success searching your position and 'line 22~24' is can't searching.

'Line 11~12' is getting current position.

'Line 13' is marker option.

'Line 14~17' display current position and marker.

'Line 18' is click listener for marker.

'Line 19~21' is info window.

I ran my mobile device.

This is result.

This is init status.

I click to search button.

I click to marker.


Jun 25, 2014

Image size changing in HTML




1. Using Style.

This is Style code

  1. <style>
  2.     img{
  3.         width:30%;
  4.     }
  5.     img:hover{
  6.         transition-property:width;
  7.         transition-duration:1s;
  8.         width:50%;
  9.     }
  10. </style>
" img{} "means img's init status.

" img:hover{} " means mouse pointer's on the img.

"transition-property" means event property. so width is change.

"transition-duration" means event time.



This is initial status. 

This is mouse hover status.


2. Using JavaScrpit & class

You need a JavaScript code

  1. <script type="text/javascript">
  2.     $(document).ready(function() {
  3.         $("#pic").click(function(){
  4.             if($(this).hasClass("small")){
  5.                 $("#pic").addClass("large") ;
  6.                 $("#pic").removeClass("small") ;
  7.                
  8.             }
  9.             else{
  10.                 $("#pic").addClass("small") ;
  11.                 $("#pic").removeClass("large") ;               
  12.             }
  13.         });
  14.     });
  15. </script>
"$("id").click " similar click listener.

"$(this).hasClass("class")" check class. If it has a class that return true. else false.

So. If #pic has a small class, add large class and remove small class.

This is style code

  1. <style>
  2.     #pic{
  3.         -webkit-transition-property:width;
  4.         -webkit-transition-duration:1s;
  5.     }
  6.     .small{
  7.         width30%;
  8.     }
  9.     .large{
  10.         width:50%;
  11.     }
  12.    
  13. </style>
small class size is 30% and large class size is 50%

This is image code
  1. <img class="small" id="pic"src="http://images.forbes.com/media/lists/companies/google_200x200.jpg"/>
image infomation.



This is before click

This is after click.

Gallery page using photoswipe



PhotoSwipe is very easy & powerful library for gallery.

First step - prepare file.

You get library phothswipe site & unzip. and copy to your project folder.

My case, I copy to C:/Program Files (x86)/Apache Group/Apache2/htdocs/photoswipe/

Second step - add library.

Change to photswipe's jquery library.

Add this code.

  1. <!--photoswipe css-->
  2. <link rel="stylesheet" href="photoswipe/lib/jquery.mobile-1.0a4.1/jquery.mobile-1.0a4.1.min.css" />
  3. <link href="photoswipe/photoswipe.css" type="text/css" rel="stylesheet"/>
  4. <style type="text/css">
  5.         div.gallery-row:after { clearbothcontent"."displayblockheight0visibilityhidden}
  6.         div.gallery-item { floatleftwidth33.333333%}
  7.         div.gallery-item a { displayblockmargin5pxborder1px solid #3c3c3c}
  8.         div.gallery-item img { displayblockwidth100%heightauto}
  9.         #Gallery1 .ui-content#Gallery2 .ui-content { overflowhidden}
  10. </style>
  11. <!--photoswipe js-->
  12. <script type="text/javascript" src="photoswipe/lib/jquery-1.6.1.min.js"></script>
  13. <script type="text/javascript" src="photoswipe/lib/jquery.mobile-1.0a4.1/jquery.mobile-1.0a4.1.min.js"></script>
  14. <script src="photoswipe/lib/simple-inheritance.min.js" type="text/javascript"></script>
  15. <script src="photoswipe/lib/jquery.animate-enhanced.min.js" type="text/javascript"></script>
  16. <script src="photoswipe/code-photoswipe-jQuery-1.0.11.min.js"></script>
  17. <script type="text/javascript">
  18.     $(document).ready(function(e) {
  19.        $('div.gallery-page').live('pageshow',function(e){
  20.            $("div.gallery a", e.target).photoSwipe();
  21.            return true;
  22.        })
  23.     });
  24. </script>

Third step - Implement gallery.

  1. <div data-role="page" id="equip-image" class="gallery-page">
  2.     <div data-role="header" data-position="fixed" >
  3.             <h1>Equipment Image</h1>
  4.             <a href="#page" data-role="button" data-icon="home" data-iconpos="notext" class="ui-btn-right" data-iconshadow="false">
  5.             </a>
  6.         </div>
  7.     <div data-role="content">  
  8.             <div class="gallery">
  9.             <div class="gallery-row">
  10.                     <div class="gallery-item">
  11.                     <a href="http://jme21.co.kr/004/images/eqip_01_01.jpg" rel="external">
  12.                         <img   src="http://jme21.co.kr/004/images/eqip_01_01.jpg" alt="TSA-J"/>
  13.                     </a>
  14.                     </div>
  15.                     <div class="gallery-item">
  16.                     .....
  17.                 </div>
  18.            
  19.            </div>
  20.         </div>
  21.    
  22.     <div data-role="footer" align="center" data-position="fixed">
  23.         <img width="100%" src="http://jme21.co.kr/images/copyright_05.jpg" />
  24.     </div>
  25. </div>
You add class "gallery-page" page tag.

In content tag you consist

<div class="gallery">
    <div class="gallery-row">
        <div class="gallery-item>
            <a href="img src"><img src=thumb nail img alt=image name/>
       </div>
   </div>
</div> 

You can see this...

If you click image..


You can see gallery.



J-query Tip



1. Change the style by browser size.

We use this code.

<link href="size_1.css" rel="stylesheet" type="text/css" media="screen and(max-width:Apx)">

example


  1. <link href="mobile.css" rel="stylesheet" type="text/css" media="screen and (max-width:599px)">
  2. <link href="desktop.css" rel="stylesheet" type="text/css" media="screen and (min-width:600px)">
line 1 means screen size(width) smaller than 599px is mobile page.

line 2 means screen size(width) larger than 600px is pc page.

If my body code is this

  1.     <div id="pc_view">
  2.         <p >
  3.             <span>T</span>
  4.                 his is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.
  5.         </p>
  6.     </div>
  7.    
  8.     <div id="mobile_view">
  9.         <p>
  10.             <span><img src="http://www.w3.org/Icons/WWW/w3c_home_nb"></span>
  11.                 This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.This is example.</p>
  12.    </div>
You can see this

This is mobile page!! 

This is PC page!!



2. Apply to common style.

We will using 'style tag' in head tag.

<style>
   your style code.
</style>

example
  1. <style type="text/css">
  2.     h2{
  3.     color:#F00;
  4.     }
  5. </style>
This example means 'h2' tag's color is red .

If my body code is
  1. <h3> You can see change view.</h3>
  2. <h2> You can see change view.</h2>
You can see this



3. Using special font 

Using this style tag.

font-family:your font...;

example

  1. h2{
  2.     color:#F00;
  3.     font-family:Arial, Helvetica, sans-serif;
  4.     font-size:15px;
  5. }
  6. h4{
  7.     color:#0F0;
  8.     font-family:"Comic Sans MS", cursive;
  9.     font-size:15px;
  10. }
You can see this




Jun 23, 2014

do it mission 9



This mission is using page link and auto back button.

I consist one file(html)

This is first page(main)

  1. <div data-role="page" id="page" data-theme="b" >
  2.     <div data-role="header" >
  3.         <h1>Page One</h1>
  4.     </div>
  5.     <div data-role="content">  
  6.        
  7.             <a href="#page2" data-transition="slide" class="ui-btn ui-shadow ui-corner-all ui-btn-icon-right ui-icon-carat-r" data-transition="slide">Page Two</a>
  8.            
  9.            
  10.     </div>
  11.     <div data-role="footer">
  12.         <h4>Page Footer</h4>
  13.     </div>
  14. </div>

This is second page.

  1. <div data-role="page" id="page2" data-theme="b"   >
  2.     <div data-role="header" data-add-back-btn=”true” >
  3.         <h1>Page Two</h1>
  4.        
  5.     </div>
  6.     <div data-role="content">  
  7.         <a href="#page3" data-transition="slide" class="ui-btn ui-shadow ui-corner-all ui-btn-icon-right ui-icon-carat-r" >Page Three</a>
  8.        
  9.            
  10.     </div>
  11.     <div data-role="footer">
  12.         <h4>Page Footer</h4>
  13.     </div>
  14. </div>

compare pages.

Can you finding what is different?

line 2 is different.

second page added "data-add-back-btn="true"".

This code making automatically  add "back" button.

So we use second page.

Maybe don't need for first page.

And line 7 is page link.

<a href="#page name" > linked tag that is name is  "page name".

So if you click this button, open this page.

This is first page.

If you click page Two.

You can see second page.

And see back button.