It appears that unless I type the latitude and longitude into the location fields, GMap is unable to display that location on a GMap view. Please provide a way to "boil down" a valid address to lat/long.

Comments

Aren Cambre’s picture

There is a possibility this is really a user interface error. When I created a GMap view without adding any Location fields, I got a validation warning saying I need to add lat/long. If in fact address fields will work, too, then it needs to say that.

bdragon’s picture

Hmm, that's a good idea. I can expand the marker creator to use the geocoder if there's an address attached to the marker and no lat/lon.

mgifford’s picture

Ideally you'd be able to specify an address for a marker and have it show up on the map. Just like you can here:
http://www.google.com/apis/maps/documentation/geocoder2.html

The address.js file is being loaded so this functionality should be available - I just can't find how it would be available through the gmap macro.

I suspect it gets pulled out with:
gmap_widget_setup($form[$fields['address']], 'locpick_address');

But am not sure how to define it, especially with the Lat/Long.

Anyways, would be very useful if we could just use a postal code to place a dot on the map. google's api supports it (for some countries), does this module?

Mike

smitty’s picture

I think it would be a great feature to retrieve the long/lat just from a postal address.

I suggest putting in a button "Retrieve coordinates" near the Address-Fields of the location module, which retrieves the long/lat-Information from google maps and sets sthe marker in the map. In the second step the user could improve the latitude and longitude on a gmap in an interactive fashion (because the postal address based search in google map is not always accurate).

gmclelland’s picture

In my humble opinion this is the only core feature that GMap is currently missing.

Is there any plans on integrating this feature into this module?

It sure would be much more convenient to simply enter a valid address and have the module geocode that location for you instead of the user having to manually search on a map to plot the address.

This is great module with a lot of potential.

bdragon’s picture

Really? This isn't a difficult feature to add. I guess the biggest problem would be how to represent it when using macros. The actual code to do geocoding and such is already there, I just need to write a little bit of glue.

ray007’s picture

I also think extending address.js to also work with location address input forms would be a good idea.
We don't really need to express that somehow for macro definition, do we?

tostinni’s picture

Subscribing.
I think this would be a very nice feature to be able to add a small search box with a button to positionate the map on a given direction, it's faster than clicking in the map, especially given the fact that outside US, Europe and some other countries, google doesn't have cities names.
For example, if you go to google maps, you can find the exact position of a city like "merida" in mexico, you won't see it on the map, but you'll retrieve the exact lat/lon.

bdragon’s picture

OK, after looking at this for a bit yesterday, it is tougher than anticipated.

I need a way to do this during preparemarker and before addmarker. Unfortunately, the geocoding is async, so it would continue on right away and try to add the not finished marker.....

I suppose I could make preparemarker responsible for firing the addmarker event....

mikelove’s picture

subscribing

smitty’s picture

Did you see what is gonig on at: http://drupal.org/node/165040 ? What do you think about this?

bdragon’s picture

http://drupal.org/node/156535 marked as duplicate

capellic’s picture

Any progress on this? I am new to GMAPing, so I'm not sure I'm approaching it the best way, but I would like to use GMAP for it's API. I'm actually using Drupal 6, but I suspect the code is in sync.

I have some CCK fields in my node that I'm using as an address - street, city, state, zip. There is no geocoding going on. I want to pass the address into the GMAP API from the node's tpl file. I see this code snippet:

$mymap=array('id' => 'mymap',
  'latitude' => '49.19258642226091',
  'longitude'=>' -123.17647933959961',
  'zoom' => 10,
  'width' => '100%',
  'height' => '200px',
  'type' => 'map',
  'markers' => array(array(
    'markername' => 'small red',
    'latitude' => '49.19258642226091',
    'longitude' => ' -123.17647933959961',
  )),
);
echo theme('gmap', array('#settings' => $mymap));

But since I don't have the long/lat, I want to pass in the address -- something like this:

$mymap=array('id' => 'mymap',
  'address' => '555 9th St, Brooklyn, NY 12345',
  'zoom' => 10,
  'width' => '100%',
  'height' => '200px',
  'type' => 'map',
  'markers' => array(array(
    'markername' => 'small red',
     'address' => '555 9th St, Brooklyn, NY 12345',
  )),
);
echo theme('gmap', array('#settings' => $mymap));

Or maybe there is a function I can call before to get the long/lat back and then set it to the first array above?

skjalf’s picture

I am new at this so forgive me if this is not applicable.

We did this by using the location module along with the gmap module.
If you use the Location module and enter address data there, it automatically geocodes it into lat/long... I was able to enter address data without zip code and get an accurate lat/long that showed up with the gmap module.

Location 3.0 module came out just a couple days ago, the same day as gmap 1.0 and also by bdragon:
http://drupal.org/project/location

Aren Cambre’s picture

I wonder if bdragon is behind on clearing already-satisfied issues? The issues list is pretty long.

Aren Cambre’s picture

Version: 5.x-1.x-dev » 6.x-1.x-dev

Bumping to current version.

muzzled’s picture

I have debugged the problem. Retrieving the long/lat just from a typed-in postal address in locpick mode actually works in the current gmap version gmap-6.x-1.1-rc1. The problem was that js/address.js isn't loaded by the browser and I cannot find anywhere within the module that adds it to the list to be loaded.

I got it working by modifying function gmap_gmap() in gmap.module,

from:

      if (isset($map['behavior']['locpick']) && $map['behavior']['locpick']) {
        drupal_add_js($path .'locpick.js');
      }

to:

      if (isset($map['behavior']['locpick']) && $map['behavior']['locpick']) {
        drupal_add_js($path .'locpick.js');
        drupal_add_js($path .'address.js');
      }

Hope it helps!

Gary

crutch’s picture

subscribe

treebykooba’s picture

subscribe

treebykooba’s picture

@muzzled (Gary) thanks for posting this.... i tried it and still can't get locpick to work. it's grayed out in my options. how do i set the map in locpick mode? i see that neither locpick.js nor address.js are loading in my browser...any ideas?
thanks!

muzzled’s picture

Hi treebykooba,

You should be able to perform this simple test. if you have "Location Search" enabled from the modules page, you should be able to navigate to search/location and see a location search form. Uncollapse the "Advanced Search", you will find a "Proximity" collapsed block, open that, you will see a locpick-able google map, and a field labeled "Locate Address". You should see locpick.js loaded with this page.

Before the mod above, typing a valid address into "Locate Address" and tabbing away has no effect. After the mod, you should see that address.js is now loaded with locpick.js, and that tabbing away from the field will trigger a redraw of the map to the location you typed in.

If you have created your own gmap in a form, I believe there is a macro "locpick" you must include in the "behavior" in order to trigger the locpick mode. I believe it is in the documentation. For my form, I just reuse what's in the already configured variable - variable_get('location_search_map_macro', ...).

Hope this helps, let us know if you got it working.

Gary

treebykooba’s picture

Hi Gary,

Thanks so much for your help! I had the Location Search module enabled but when I go to create a story where I have the gmap/location macro there are no "advanced search" options or "proximity" blocks...just a location where the user can put in the address and drag and drop in a map. I found the GMAP-MACRO-DICTIONARY.txt file and there is nothing about a locpick behavior to place in the macro. Just basic attributes and overlays. I don't see anything about behaviors. Could this info be in any other file? Any other ideas?

Thanks sooo much for any info!

TK

heshanlk’s picture

sub