<form action="user-geolocation-confirm.php" method="post" name="myform" class="form-horizontal"> <div class="row"> <div class="col-md-4"> <div class="form-group"> <label for="latitude" class="control-label col-xs-4">Latitude</label> <input type="text" id="lat1" value="<?php echo $fetch['latitude'];?>" name="latitude"> </div> </div> <div class="col-md-4"> <div class="form-group"> <label for="longitude" class="control-label col-xs-4">Longitude</label> <input type="text" id="lang1" value="<?php echo $fetch['longitude'];?>" name="longitude"> </div> </div> <div class="col-md-4"> <div class="form-group"> <input type="submit" name="submit" class="btn btn-success" value="Save"> <?php $url= htmlspecialchars($_SERVER['HTTP_REFERER']); echo "<a href='$url' class='btn btn-warning'> Back / Cancel</a>" ;?> </div> </div> </div> </form> <?php if(!empty($fetch['longitude']) && !empty($fetch['latitude'])){ ?> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type="text/javascript"> var addssByGoogle='<?=$fetch['latitude']?>,<?=$fetch['longitude']?>'; var geocoder; var map; var infowindow = new google.maps.InfoWindow(); var marker; function initialize(address,xLocation,yLocation) { codeLatLng(address,xLocation,yLocation) ; } function codeLatLng(address,xLocation,yLocation) { var latlng = new google.maps.LatLng(xLocation,yLocation); var myOptions = { center: latlng, mapTypeId: 'roadmap' } geocoder = new google.maps.Geocoder(); map = new google.maps.Map(document.getElementById("map_canvas1"), myOptions); geocoder.geocode({'latLng': latlng}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { if (results[0]) { if('1.366667'==xLocation && '103.8'==yLocation) { map.setZoom(9); } else { map.setZoom(12); } marker = new google.maps.Marker({ position: latlng, map: map, title: address }); addssByGoogle = results[0].formatted_address; //infowindow.setContent(results[0].formatted_address); infowindow.setContent(address); infowindow.open(map, marker); } else { // alert("No results found"); } } else { // alert("Geocoder failed due to: " + status); } }); } </script> <div id="map_canvas1" style="width:100%; height:300px;"></div> <script type="text/javascript"> initialize("Latitude: <?=$fetch['latitude']?><br/> Longitude: <?=$fetch['longitude']?>","<?=$fetch['latitude']?>","<?=$fetch['longitude']?>"); </script> <?php } else {?> <div id="googlemaps">The Postal Address Finder is powered by Google Maps. Loading..</div> <!-- <script src="jquery.min.js.pagespeed.jm.TiC1blcYSb.js"></script> <script src="bootstrap.min.js.pagespeed.jm.Rzv0qKF99s.js"></script> <script>//<![CDATA[ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create','UA-50062-24','ctrlq.org');ga('send','pageview'); //]]></script> --> <script>//<![CDATA[ (function(){var d=encodeURIComponent,f=window,g=document,h="documentElement",k="length",l="prototype",m="body",p="&",s="&ci=",t=",",u="?",v="Content-Type",w="Microsoft.XMLHTTP",x="Msxml2.XMLHTTP",y="POST",z="application/x-www-form-urlencoded",A="img",B="input",C="load",D="oh=",E="on",F="pagespeed_url_hash",G="url=";f.pagespeed=f.pagespeed||{};var H=f.pagespeed,I=function(a,b,c){this.c=a;this.e=b;this.d=c;this.b=this.f();this.a={}};I[l].f=function(){return{height:f.innerHeight||g[h].clientHeight||g[m].clientHeight,width:f.innerWidth||g[h].clientWidth||g[m].clientWidth}};I[l].g=function(a){a=a.getBoundingClientRect();return{top:a.top+(void 0!==f.pageYOffset?f.pageYOffset:(g[h]||g[m].parentNode||g[m]).scrollTop),left:a.left+(void 0!==f.pageXOffset?f.pageXOffset:(g[h]||g[m].parentNode||g[m]).scrollLeft)}};I[l].h=function(a){if(0>=a.offsetWidth&&0>=a.offsetHeight)return!1;a=this.g(a);var b=a.top.toString()+t+a.left.toString();if(this.a.hasOwnProperty(b))return!1;this.a[b]=!0;return a.top<=this.b.height&&a.left<=this.b.width};I[l].i=function(a){var b;if(f.XMLHttpRequest)b=new XMLHttpRequest;else if(f.ActiveXObject)try{b=new ActiveXObject(x)}catch(c){try{b=new ActiveXObject(w)}catch(e){}}if(!b)return!1;b.open(y,this.c+(-1==this.c.indexOf(u)?u:p)+G+d(this.e));b.setRequestHeader(v,z);b.send(a);return!0};I[l].k=function(){for(var a=[A,B],b=[],c={},e=0;e<a[k];++e)for(var q=g.getElementsByTagName(a[e]),n=0;n<q[k];++n){var r=q[n].getAttribute(F);r&&(q[n].getBoundingClientRect&&this.h(q[n]))&&!(r in c)&&(b.push(r),c[r]=!0)}if(0!=b[k]){a=D+this.d;a+=s+d(b[0]);for(e=1;e<b[k];++e){c=t+d(b[e]);if(131072<a[k]+c[k])break;a+=c}H.criticalImagesBeaconData=a;this.i(a)}};Hj=function(a,b,c){if(a.addEventListener)a.addEventListener(b,c,!1);else if(a.attachEvent)a.attachEvent(E+b,c);else{var e=a[E+b];a[E+b]=function(){c.call(this);e&&e.call(this)}}};Hl=function(a,b,c){var e=new I(a,b,c);Hj(f,C,function(){f.setTimeout(function(){ek()},0)})};H.criticalImagesBeaconInit=Hl;})();pagespeed.criticalImagesBeaconInit('/mod_pagespeed_beacon','http://ctrlq.org/maps/address/','4CgYGHYGDX'); //]]></script> <?php }?> </div>
Solutions Collecting From Web of "Как обновить карту, когда отображение карты основано на долготе и широте, т.е. выборка из базы данных"