Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Map Issue on Onclick of A Button
    primarykey
    data
    text
    <p>I have a codeigniter application to load google map.This is my view page code when i clicking on the button view_map_box() function is called.</p> <pre><code>function view_map_box() { var cnt=$("#search_agency_res").serialize(); var region = $("#agency_region").val(); var country = $("#agency_country").val(); var agency = $("#agency_agency").val(); if(region == "") { $("#lsitAlert").show(); $("#lsitAlert").html("&lt;img src='&lt;?php echo base_url();?&gt;Images/exclamationR.png' style='float:left;'/&gt;&amp;nbsp;&amp;nbsp;&lt;div style='float:left;margin-top:8px;'&gt;Select A region&lt;/div&gt;"); $("#lsitAlert").css("background-color","#a90b05"); $("#addAlert").css("padding","0px"); $("#agency_region").css("border","1px solid #f9612c"); $("#agency_region").css("border-radius","5px"); return false; } else { $.ajax({ type: "POST", url: "&lt;?php echo base_url();?&gt;index.php/addAgency/agency_map_result/"+region+"/"+country+"/"+agency, data: cnt, success: function(valmsgnew){ $("#map").css("display","block"); $("#map").html(valmsgnew).show(); } }); } } </code></pre> <p>This is controller code</p> <pre><code>function agency_map_result($region,$country = "",$agency = "") { $data['values'] = $this-&gt;pms_agency_model-&gt;search_map($region,$country,$agency); echo $this-&gt;load-&gt;view('admin/markers',$data); } </code></pre> <p>This is model code</p> <pre><code>function search_map($region,$country = "",$agency = "") { extract($_POST); $aregion = $_POST['agency_region']; $acountry = $_POST['agency_country']; $aagency = $_POST['agency_agency']; if($aregion != "" &amp;&amp; $acountry == "" &amp;&amp; $aagency == "") { $this-&gt;db-&gt;where('tblagencies.varregion',$aregion); return $val = $this-&gt;db-&gt;get('tblagencies')-&gt;result(); } else if($aregion != "" &amp;&amp; $acountry != "" &amp;&amp; $aagency == "") { $this-&gt;db-&gt;where('tblagencies.varregion',$aregion); $this-&gt;db-&gt;where_in('varcountry', $acountry); return $val = $this-&gt;db-&gt;get('tblagencies')-&gt;result(); } else if($aregion != "" &amp;&amp; $acountry != "" &amp;&amp; $aagency != "") { $this-&gt;db-&gt;where('tblagencies.varregion',$aregion); $this-&gt;db-&gt;where_in('varcountry', $acountry); $this-&gt;db-&gt;where('tblagencies.intaid',$aagency); return $val = $this-&gt;db-&gt;get('tblagencies')-&gt;result(); } } </code></pre> <p>This is the map page is loading..</p> <pre><code>&lt;?php function get_latlng($cityname) { $city = urlencode($cityname); $Url='http://maps.googleapis.com/maps/api/geocode/json?address='.$city.'&amp;sensor=false'; if (!function_exists('curl_init')){ die('Sorry cURL is not installed!'); } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $Url); curl_setopt($ch, CURLOPT_REFERER, "http://www.example.org/yay.htm"); curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $output = curl_exec($ch); curl_close($ch); $search_data = json_decode($output); if($search_data-&gt;results) { $new = array("lat"=&gt;$search_data-&gt;results[0]-&gt;geometry-&gt;location-&gt;lat,"lng"=&gt;$search_data-&gt;results[0]-&gt;geometry-&gt;location-&gt;lng); return $new; } } ?&gt; &lt;style&gt; .gmap3{ margin: 20px auto; border: 1px dashed #C0C0C0; width: 500px; height: 500px; } &lt;/style&gt; &lt;script type="text/javascript"&gt; $(function(){ $('#test1') .gmap3( { action:'init', options:{ center:[53.067627,-1.625977], &lt;?php if($values) {?&gt; zoom: 5 &lt;?php } else{ ?&gt; zoom: 2 &lt;?php } ?&gt; } }, { action: 'addMarkers', markers:[&lt;?php if($values) { foreach($values as $rows) { $varmetro = $rows-&gt;varmetro; $newvar = explode(',',$varmetro); $count = count($newvar); for($i=0;$i&lt;$count;$i++) { $sql='SELECT * FROM `tblcity` WHERE `intcityid`='.$newvar[$i].''; $res=mysql_query($sql); $sql_res=mysql_fetch_row($res); $cityname =$sql_res[2]; $new = get_latlng($cityname); //print_r($new); ?&gt; {lat:&lt;?php echo $new["lat"];?&gt;, lng:&lt;?php echo $new["lng"];?&gt;,data:'&lt;?php echo $cityname;?&gt;&lt;br&gt;&lt;br&gt;&lt;?php echo "Agency : ".$rows-&gt;varagencyname;?&gt; '}, &lt;?php }}}?&gt;], marker:{ options:{ draggable: false }, events:{ mouseover: function(marker, event, data){ var map = $(this).gmap3('get'), infowindow = $(this).gmap3({action:'get', name:'infowindow'}); if (infowindow){ infowindow.open(map, marker); infowindow.setContent(data); } else { $(this).gmap3({action:'addinfowindow', anchor:marker, options:{content: data}}); } }, mouseout: function(){ var infowindow = $(this).gmap3({action:'get', name:'infowindow'}); if (infowindow){ infowindow.close(); } } } } } ); }); &lt;/script&gt; &lt;div id="test1" class="gmap3" style="width:700px;"&gt;&lt;/div&gt; </code></pre> <p>But when calling this function view_map_box() the map is not loaded it loads some other view page.And also produce a warning in firebug</p> <pre><code>A call to document.write() from an asynchronously-loaded external script was ignored. </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload