tiz a thing of beauty. Thanks a lot Hamish, much appreciated. I have one more nice-to-have. I have added code to make a draggable marker, and what I really want is to have the marker return its lat and lng on drop.
I can see in the gmaps docs that addListener is the way to go, but I dont know how to implement that with jmap getting in the way. Can you help me once more? (function($){ //$.fn.jMap.defaults.mapType = "sat"; $('#map').jmap({language:"en",mapCenter:[-25.274398,133.775136 ],mapZoom:4}); $('#map').createMarkerManager(); $('#map').createGeoCache(); $('#addressSearch').click(function(){ if (typeof $.jmap.GClientGeocoder == 'undefined') { var geocoder = new GClientGeocoder; } else { var geocoder = $.jmap.GClientGeocoder; } geocoder.getLatLng($('#fromAddress').val() + ', australia', function(point){ if (!point){ // Address is not found, throw an error alert('Address not found'); }else{ $.jmap.GMap2.setCenter(point,17); $('#addresslat').val(point.y) $('#addresslng').val(point.x) // Add marker to map var marker = $('#map').addMarker({pointLat: point.y,pointLng:point.x,isDraggable:true}); } }); }); })(jQuery); On Jan 17, 2008 9:53 PM, Hamish Campbell <[EMAIL PROTECTED]> wrote: > > 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.jsfile, > > 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] > -- Duncan I Loxton [EMAIL PROTECTED]