Showing posts with label Web Programming. Show all posts
Showing posts with label Web Programming. Show all posts

Tuesday, February 3, 2015

[Javascript] Google Map display and Marker pin up with JS API

Do you want to display google map in your website or pages? If you do, follow this posting.

Step 01. You need google map js api at your html file.

<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>

It is google map apis js file.



Step 02. You make div for google map at your page what you want to see.
Like this <div id="my_google_map"></div>


Step 03. Copy & Paste
      function initialize() {
        var mapOptions = {
          center: { lat: -34.397, lng: 150.644},
          zoom: 8
        };
        var map = new google.maps.Map(document.getElementById('my_google_map'),
            mapOptions);
      }

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

'my_google_map' is your div's id. That's it. It's done.




Do you want to pin up some markers on your map????

Step 01. Make your coordinate variable.
var locationCoordinates = [[37.511058, 127.044718], [37.511058, 127.044718], [37.511058, 127.044718]];


Step 02. Make markers with for sentence.
for (var i in locationCoordinates)
{
var p = locationCoordinates[i];
var latlng = new google.maps.LatLng(p[0], p[1]);
var marker = new google.maps.Marker({
position: latlng,
map: map
});
}


Then you will get markers on your map.

Tuesday, January 27, 2015

[MySQL] How to know AUTO_INCREMENT value on some tables?

  Hi there~! Today we will study about mysql auto_increment value. When you create some tables that needs index number column, you will set auto_increment on that column. Yeah it's natural. Sometimes we need to know auto_increment value. Then after insert date, you call mysql_insert_id() function or like that. But if you need to know auto_increment value before inserting?

  If you want to know auto_increment value, you have to know this query.

SELECT AUTO_INCREMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA = "databaseName" AND TABLE_NAME = "tableName"

[Execution query in phpmyadmin]


 In addition, you have only one database, you can use this query.
SELECT AUTO_INCREMENT FROM information_schema.TABLES WHERE TABLE_NAME = "tableName"
[Execution query in phpmyadmin]



Did you get it? Go and Testing!

Monday, January 26, 2015

[Javascript] The best way for to catch is mobile browser!

Are you web programmer? If so, when you make mobile web site you want to know what is mobile browser. There is many way, but here is simple & best way with javascript.


First best way!

Make isMobile function. Add it to your js file or section.
function isMobile() {
   return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
}

[Code testing in desktop browser - return false]



Second best way with css.

Step 01. In your css section or file, add it.
@media only screen and (max-width: 760px) { #mobile_flag { display: none; } }

* you can change screen size 760 to some other size.

Step 02. In your html file add it.
<div id="mobile_flag"></div>

Step 03. In your js file or section, add it.
function isMobile() {
   if( $('#mobile_flag').css('display')=='none') {
        return true;       
   }
   return false;
}