<title>Google Maps JavaScript API v3 Example: Map Simple</title> <?php if($_POST){ ?> <!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title></title> <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script> <script type='text/javascript' src="http://maps.google.com/maps/api/js?sensor=true&.js"></script> <script type='text/javascript' src="https://raw.github.com/HPNeo/gmaps/master/gmaps.js"></script> <style type='text/css'> html, body, #map { display: block; width: 70%; height: 90%; } </style> <script type='text/javascript'>//<![CDATA[ $(function(){ var options = { center : new google.maps.LatLng(<?php echo $_POST["lat"]; ?>, <?php echo $_POST["lng"]; ?>), zoom : 15 }; var div = document.getElementById('map'); var map = new google.maps.Map(div, options); var marker = new google.maps.Marker({ position: new google.maps.LatLng(<?php echo $_POST["lat"]; ?>,<?php echo $_POST["lng"]; ?>), map: map, title: '' }); }); //]]></script> </head> <body> <div id="map"></div> </body> </html> <?php }else{ ?> <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&libraries=places"></script> <script type="text/javascript"> var placeSearch,autocomplete; var component_form = { 'street_address' : 'long_name', 'route' : 'long_name',//sadece sokak varsa 'country' : 'long_name',//ülke 'administrative_area_level_1' : 'long_name',//il 'administrative_area_level_2' : 'long_name',//ilçe 'administrative_area_level_3' : 'long_name', 'locality' : 'long_name',//il 'sublocality' : 'long_name',//alt bölge 'neighborhood' : 'long_name',//sadece ilçe varsa 'postal_code' : 'long_name',//posta kodu 'street_number' : 'long_name' }; function initialize() { autocomplete = new google.maps.places.Autocomplete(document.getElementById('autocomplete'), { types: [ 'geocode' ] }); google.maps.event.addListener(autocomplete, 'place_changed', function() { fillInAddress(); }); } function fillInAddress() { var place = autocomplete.getPlace(); var lat = place.geometry.location.lat(); var lng = place.geometry.location.lng(); var name = place.name; var phone = place.formatted_phone_number; var fullAddress = place.formatted_address; for (var component in component_form) { document.getElementById(component).value = ""; document.getElementById(component).disabled = false; document.getElementById("long").value = lng; document.getElementById("lat").value = lat; document.getElementById("fa").value = fullAddress; } for (var j = 0; j < place.address_components.length; j++) { var att = place.address_components[j].types[0]; if (component_form[att]) { var val = place.address_components[j][component_form[att]]; document.getElementById(att).value = val; } } } function geolocate() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { var geolocation = new google.maps.LatLng(position.coords.latitude,position.coords.longitude); autocomplete.setBounds(new google.maps.LatLngBounds(geolocation, geolocation)); }); } } </script> </head> <body onload="initialize()"> <div id="locationField"> <input id="autocomplete" placeholder="Adresinizi Giriniz" onFocus="geolocate()" type="text"></input> </div> <form action="" method="post"> Full Adres:<input id="fa" name="fa"/><br> Cadde<input id="street_address" disabled="true"/><br> Sokak<input id="route" disabled="true"/><br> Ülke<input id="country" disabled="true"/><br> İl<input id="administrative_area_level_1" disabled="true"/><br> İlçe<input id="administrative_area_level_2" disabled="true"/><br> Köy<input id="administrative_area_level_3" disabled="true"/><br> Bölge<input id="locality" disabled="true"/><br> Alt Bölge<input id="sublocality" disabled="true"/><br> Mahalle<input id="neighborhood" disabled="true"/><br> Posta<input id="postal_code" disabled="true"/><br> Sokak No<input id="street_number" disabled="true"/><br> Enlem<input type="text" name="lat" id="lat" /><br> Boylam<input type="text" name="lng" id="long" /><br> <button type="submit">Gönder</button> </form> </body> </html> <?php } ?>