Closed (outdated)
Project:
GMap Module
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
1 Sep 2010 at 16:10 UTC
Updated:
18 Sep 2021 at 14:10 UTC
Jump to comment: Most recent
Comments
Comment #1
michelleHere's the code involved:
In
function gmap_gmap()Then in address.js, comment out every line that sets the address field back to "Enter an address". We want to keep the data in that field so never clear it out, even if they move the marker on the map to correct a bad geocoding. Maybe this could be done with a setting or perhaps just use a different .js file?
Finally, this bit of custom code goes in hook_form_alter() for the form with the address field. It attaches the map to the address field and makes it all work together. It would need to either be generalized to know what field names you're using or require using specific names for the fields. One thing to watch out for is that if you put your field in a fieldset, the fieldset needs to be added to the code as well.
Comment #2
drupalfan81 commentedWhich file is this function in?
function gmap_gmap()
Can you please specify so the rest of us can test this out?
Thanks!
Comment #3
hutch commentedgrep -rn 'gmap_gmap(' *
finds it in gmap.module, line 96
Comment #4
ccheu commentedMichelle,
Thanks for the information. I am using Node Locations from the Locations module. I've created a content type activated Node Locations for this type. But I still can't seem to make the GMap do the geocoding locpick from the Street address.
Where do I enter the codes for the mod concerning the hook_form_alter() ? Are there any changes required to the code or do I just slot it somewhere in a file? For my case, is it the location_node.module file? But where do I slot it?
By the way, I have successfully done first two parts of your suggestion (add address.js and comment out the "Enter an Address." Works well when I go to "/search/location" under the "Advance Search/Proximity" section. Thanks for that!
Regards,
Chang
Comment #5
michelle@ccheu: It's meant to go in your own module and, no, it can't be just dropped in as is. If you don't know how to use form alters, you should read up on FAPI first.
Michelle
Comment #6
Madis commentedThanks Bdragon for writing and Michelle for sharing the code! Helped me out immensely in both adding the mentioned gmap functionality to a content type with CCK textfields and creating a custom form with the same features. I managed to avoid hacking GMap module files by creating a copy of address.js (customized and loaded it on the specific pages where I needed). It seemed like the 3 last blocks of code (setting map id-s and widgets) weren't necessary when adding the functionality to my content type CCK fields.
I needed the map to zoom in after the search as well, which I managed to do with the following code snippet (took me a while to find something that worked):
Also supporting the idea of making this an official part of GMap.
Comment #7
avpadernoI am closing this issue, as it has been created for a release that is now not supported.