google map app help |
[eluser]boony[/eluser]
Hi all, I've got a small problem with a google map app that I'm working with and hope someone can help solve this issue. Essentially, I've got a small app that places a marker on a map and then needs to save the lat and long of the position. The code supplied by GOOGLE (below) uses a JavaScript solution. The phpsqlinfo_addrow.php file gets the URI segments which pass the lat and long in the URL call. Code: function saveData() { What I want to do is get the lat and long from the marker and pass it to my controller to store the lat and long into the appropriate table. In other words I want to rewrite the following Code: var url = "phpsqlinfo_addrow.php?name=" + name + "&address;=" + address + into something that CI can handle. Any advice (well not exactly any advice %-P ) greatly appreciated. Regards
[eluser]eoinmcg[/eluser]
Hi Boony, Try changing Code: var url = "phpsqlinfo_addrow.php?name=" + name + "&address;=" + address + Code: var url = "phpsqlinfo_addrow.php/name/" + name + "/address/" + address + Of course you'll need to change 'phpsqlinfo_addrow.php' to the name of the controller/method in your CI app You can then use $this->uri->uri_to_assoc(n) to return the segement as an associative array of key/value pairs. http://ellislab.com/codeigniter/user-gui...s/uri.html Hope that helps!
[eluser]boony[/eluser]
Quote:Of course you'll need to change 'phpsqlinfo_addrow.php' to the name of the controller/method in your CI app Thanks eoinmcg, I've been playing with this for hours and am now totally confused ( wots new I hear ![]() I'm trying to get back to the controller and am using this (which doesn't seem to work) Code: var url = "<?=site_url('mapapp/test_form'); ?>/fname/" + fname + "/lat/" + latlng.lat() + "/lng/" + latlng.lng(); Does that look ok? Also, I suspect there may be a problem in getting the JavaScript onclick to work. This is the script that is supposed to get the marker position...does CI need to do this differently??? Code: var map = new google.maps.Map(document.getElementById("map_canvas"), options);
[eluser]eoinmcg[/eluser]
Quote:I’m trying to get back to the controller and am using this (which doesn’t seem to work) If you're loading the above javascript in a *.js file the php (<?=site_url('mapapp/test_form'); ?> ![]() Quote:Also, I suspect there may be a problem in getting the JavaScript onclick to work. This is the script that is supposed to get the marker position…does CI need to do this differently??? I'm not familiar with the google supplied javascript you're using, but I'd imagine that it shouldn't cause you any problems as it all happens client side. For debugging javascript I can't recommend Firebug enough. console.log() and breakpoints are your friends! Hope that helps, if not what errors / javascript errors are you gettings? |
Welcome Guest, Not a member yet? Register Sign In |