Hmm, well this definately works: <script language="javascript" type="text/javascript"> customGeoCode = function(address) { if (typeof $.jmap.GClientGeocoder == 'undefined') { var geocoder = new GClientGeocoder; } else { var geocoder = $.jmap.GClientGeocoder; }
geocoder.getLatLng('1 queen st, auckland, new zealand', function(point){ if (!point) { // Address is not found, throw an error alert('Address not found'); } else { alert('lat: '+point.y); alert('lng: '+point.x); } }); } // test it out: customGeoCode('Auckland, New Zealand'); </script> Bypasses those functions and you don't even need a map. On Jan 17, 11:25 pm, Duncan <[EMAIL PROTECTED]> wrote: > Thanks Hamish > > I am also using jMaps2 and saw that adding addMarker:false should return the > point object, then I would have point.y and point.x this doesn't appear to > be happening though. > > I also spotted the references to what you pointed out in the jmaps.js file, > but because I am using jmap2 I guess the searchAddress function in > jmap2.jssupercedes the original. > > So when I try > > $address = $('#map').searchAddress({ > address: $('#fromAddress').val(), > cache: $.jmap.GGeoCache, > returntype: 'object', > addMarker:false > > and do an alert($address) I actually get a HTML div Object, not a data > array. Whats going on? This looks like it should be returning an array..... > > On Jan 16, 2008 7:23 PM, Hamish Campbell <[EMAIL PROTECTED]> wrote: > > > > > > > It's a great plugin - I'm using it (well, jmap2 actually) at > > isat.deft.co.nz to integrate twitter and gmaps (currently a proof of > > concept page only). > > > I believe I know where you're going wrong. By default, searchAddress > > performs actions on the current map, rather than returning something > > useful. However, add the option "returntype: 'object'" and you will > > get a an array where [0] is the 'y' (longitude?) and [1] is the 'x'. > > > So, you want something like this: > > > address = $('#map').searchAddress({ > > address: $('#fromAddress').val(), > > cache: $.jmap.GGeoCache, > > returntype: 'object' > > } > > > lat = address[1]; > > lng = address[0]; > > > I haven't tested this, but from the source code of the plugin, the > > returntype option is there explicitly to allow what you are looking > > for. > > > Hope this helps! > > > Hamish > > > On Jan 16, 6:13 pm, Duncan <[EMAIL PROTECTED]> wrote: > > > can anyone please help me with this? > > > > On Jan 15, 2008 11:35 AM, Duncan <[EMAIL PROTECTED]> wrote: > > > > > I am trying to make use of the jMaps plugin > > > >http://digitalspaghetti.me.uk/2007/11/20/jmap2-beta-release-outto > > > > retrieve the lat and long of an address so I can put it into a form > > element. > > > > > So far I have the following code, I can stop the plugin putting the > > > > pointer on the map (by adding addMarker:false ), so at least I know > > that I > > > > should be getting a variable with the point coords in it: > > > > > (function($){ > > > > //$.fn.jMap.defaults.mapType = "sat"; > > > > $('#map').jmap({language:"en"}); > > > > $('#map').createMarkerManager(); > > > > $('#map').createGeoCache(); > > > > > //console.log($.jmap); > > > > function searchCallBack(point){ > > > > alert(point); > > > > } > > > > > $('#addressSearch').click(function(){ > > > > $('#map').searchAddress({ > > > > address: $('#fromAddress').val(), > > > > cache: $.jmap.GGeoCache, addMarker:false > > > > },null,searchCallBack > > > > ); > > > > }); > > > > })(jQuery); > > > > > However the callback doesnt work properly, I have also tried > > > > $('#addressSearch').click(function(){ > > > > $('#map').searchAddress({ > > > > address: $('#fromAddress').val(), > > > > cache: $.jmap.GGeoCache, addMarker:false > > > > },null,function(point){alert(point);} > > > > ); > > > > but the function that is passed in is passed simply as text. > > > > > and I tried assigning the result to a variable : > > > > > $address = $('#map').searchAddress({ > > > > address: $('#fromAddress').val(), > > > > cache: $.jmap.GGeoCache, addMarker:false > > > > } > > > > but there was no love there either. > > > > > Any help great fully appreciated! > > > > Where am I going wrong? > > > > > -- > > > > Duncan I Loxton > > > > [EMAIL PROTECTED] > > > > -- > > > Duncan I Loxton > > > [EMAIL PROTECTED] > > -- > Duncan I Loxton > [EMAIL PROTECTED]