Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
On my site it is commong for multiple markers to be on a single lat/lon within a GMap.
Is there anything you can do to make these markers distinct, within the module itself?
If not, can you lead me in the right direction?
Cheers!
Comment | File | Size | Author |
---|---|---|---|
#18 | gmap_multiMarkers-View-Override_php.txt | 6.34 KB | kvvnn |
#18 | gmap_multiMarkers-tabs_js.txt | 17.15 KB | kvvnn |
#18 | gmap_multiMarkers_js.txt | 7.84 KB | kvvnn |
Comments
Comment #1
kvvnn CreditAttribution: kvvnn commentedUpdate : I have a funds for this request.
Elaboration : Create some sort of interface within the GMap to display multiple markers at a single location, and allow users to find and click them individually.
Comment #2
sagannotcarl CreditAttribution: sagannotcarl commentedI believe if you use Jef Poskanzer's Clusterer and set Popup mode to Original (in /admin/settings/gmap), when you click on a cluster it shows all the points within that cluster in the popup. May not be ideal but it will get you part way there.
Comment #3
super_romeo CreditAttribution: super_romeo commentedsubscribe
Comment #4
dieter CreditAttribution: dieter commentedsubscribing
Comment #5
amedee-1 CreditAttribution: amedee-1 commented+1 subscribing
I have written about this in the Location & Mapping group, but perhaps it makes more sense here.
http://groups.drupal.org/node/23164#comment-87275
I have the same issue, but with nodes, not users.
I have a test case with 2 modules with exactly the same location:
http://foutparkeerders.be/kaart
Zoom into Gent, Voskenslaan - a street in the SW of the city. There are 3 nodes in that street: one near Schoonmeersstraat and two with identical location near Tuinwijklaan. These two nodes with identical location are:
http://foutparkeerders.be/node/5
http://foutparkeerders.be/node/50
Only node/5 is shown in the popup when I use no marker manager.
I have tested the following marker managers:
No clustering
No clustering
Shows list of nodes in a popup
My settings:
Results:
I would like to see a cluster that works mostly like Jef Poskanzer's Clusterer, with the following features:
The qestion of kvnBushi was extremely short, but I think that I understand the problem. I need the same for my site. I'm confident that if I can get it to work exactly as described above, then kvnBushi will also have his solution. I tried to give as much detail as possible. Hopefully this will help a developer that wants to work on it.
Comment #6
amedee-1 CreditAttribution: amedee-1 commentedPossibly related issues:
is actually the opposite of this request. Care should be taken that both implementations still work if any work is ever done on either feature request
seems to be a bugfix for the empty-list-issue. I will try this patch later and report back here.
I found other possibly related issues, but they were more than a year old.
Comment #7
amedee-1 CreditAttribution: amedee-1 commentedUPDATE: mostly solved, seee comment http://drupal.org/node/329281#comment-1920180
kvnBushi can you confirm that this is also a solution for you?
Comment #8
kvvnn CreditAttribution: kvvnn commentedYes, that helps me.
Thanks.
Comment #9
rares CreditAttribution: rares commentedI understand that the solution on http://drupal.org/node/329281#comment-1920180 fixes some problems, but in the end that comment says that
The point of this thread was exactly to solve the problem of needing "multiple markers to be on a single lat/lon", in the clusterer zoom to cluster mode.
The only solution I've found to that is in a draft version here: http://drupal.org/node/155104#comment-1726644
Comment #10
kvvnn CreditAttribution: kvvnn commentedI have a custom built solution that using theme overrides in the view (.tpl.php) to show a list of nodes (views fields) when you click on a location within a GMap.
Its pretty specific to my site, and there is a lack of documentation, and I can't really provide support (I outsourced the functionality), but I will post here as soon as I get some time to organize some instructions.
I will post a link w/ an example and instructions, as well as the them override in a few days.
Sorry for the teaser, I just want to hold myself to it but there is no way I can handle it tonight.
Cheers!
Comment #11
kvvnn CreditAttribution: kvvnn commentedHere is our testing server for the implementation : http://test2.venuslabs.co.in/gmapTabs
Comment #12
kvvnn CreditAttribution: kvvnn commentedI'm still working on this guys. I'll probably open up a drupal install on my server as an active example, like the above. Its somewhat complicated because we used template overrides.
Soon,
Comment #13
mErilainen CreditAttribution: mErilainen commentedI'm really interested to use your implementation, as I have two different maps of users' profiles which I want to show. Other one is a map of user's home location and another one is where the user is currently studying. I don't have many overlapping locations in the home location map, but many students live in the same building, so they share the same location also.
Comment #14
kvvnn CreditAttribution: kvvnn commentedFor now, I would appreciate if you emailed me using the contact form, and once we figure out how to make it work for you we'll post some general instructions on here.
Comment #15
ChrisRut CreditAttribution: ChrisRut commented:subscribe:
Comment #16
kvvnn CreditAttribution: kvvnn commentedIf anyone wants the raw files just send me a message via contact form, and I can offer specific help. Hopefully I'll get some time to put up a proper instructional w/ attachments.
Comment #17
kvvnn CreditAttribution: kvvnn commentedDisclaimer
Alright, here goes. This can be an ugly process if we don't do it together. I expect you all to return the favor by posting issues you have, with resolves if they are found, and in general just being communicative.
Prerequisites
You need to have a working View that has a table list of latitude/longitude values plus any information pertaining to that location and its respective node, with a Gmap that displays the map of the nodes. See http://drupal.org/node/386848#comment-1368296 if you have not completely mastered Views for Location CCK + Gmap.
--------------------
Overview
Goal: to create a View that contains a list of fields pertaining to a location, with a Gmap that is designed around displaying multiple node fields for the exact same location. By location, I technically mean a specific latitude and longitude value.
The only limitation to the setup at http://drupal.org/node/386848#comment-1368296, is that multiple nodes cannot be displayed for a single location. To do this, we need to implement a Views Override. I will not provide instructions on how to do that, so go look it up if you need to, but will be providing all of the files that will make it work.
Logistics
The way we do this is to create two separate views for one Gmap + List. One view is the view that users see, and another is the view that our Gmap pulls data from. The reason we don't use a single view is due to paging limitations. For example, if we use the same view and the Gmap is pulling data from it, then it can only pull data from whatever page we are on. For my implementation I wanted all data visible on the Gmap no matter what page of the view we were on.
Begin by creating your view as laid out in http://drupal.org/node/386848#comment-1368296. Create a page that displays the list of data and an attachment that is the Gmap. Then clone it.
Static Files
gmap_multiMarkers.js and gmap_multiMarkers-tabs.js are files that should not need any customization. They are tied to our view override on line 116 and 117. You can see that their default locations are "/sites/default/files"
Custom File
gmap_multiMarkers-View-Override.php is our View Override. You will need to customize it heavily in order for it to display your fields, and not the ones I set it up for. Here is a legend by line number :
21 : MAX_FIELD_TEXT is a variable that determines the maximum amount of characters my main field should have. I am applying it on line 51 to one of my fields
22 : MAX_NODES_PER_TAB is a variable that determines the maximum amount of nodes to display per tab. Keep in mind that whatever fields you are using will be displayed per node. For example, if you are using "Node:Title" and "Node:Body" fields and make MAX_NODES_PER_TAB 5, then each tab will have the Title and Body for 5 nodes listed.
35 : $view_name is a variable that references the name of our cloned view
36 : $display is the display of the list we are shooting into our gmap. It needs to be a list from our cloned view that includes latitude and longitude of our location for that node.
46-57 : Here are the fields in our cloned view list display. It was helpful for me to install Views Customfield and follow http://drupal.org/node/467190#comment-2068324 to see how to reference the field names. All of this should be blanked out and rewritten according to your requirements. As you can see I have some popups functionality in there as well.
70 : GMaps API Key
113,114 : Popups Stuff
116,117 : Our required javascript files
118 : This is where we pring out the Gmap. You would put whatever styling values you want here
122-139 : This is where we insert our fields in the Gmap. You'll see on line 134 we are guarding against special characters that will break the Gmap.
145-161 : This is where we insert our fields for a Gmap popup that does not have enough nodes for two tabs.
170 : This is where we print our list. If you guys only want to print a Gmap, you can delete this entire table
Whew. Ask away.
Comment #18
kvvnn CreditAttribution: kvvnn commentedComment #19
ChrisRut CreditAttribution: ChrisRut commentedThanks for the great post Kevin,
Where did you get the files for lines 114-117 in the views override?
Am I to assume from the files you posted that:
gmap_multiMarkers-tabs_js.txt = /sites/default/files/tabbed.js
gmap_multiMarkers_js.txt = /sites/default/files/advice_gmap.js
If so where is the /modules/popups/popups.js file?
Is that the popups API module? If so you should probably update your post and add popups API module to the Prerequisites.
Thanks again for posting the instructions+code
Comment #20
kvvnn CreditAttribution: kvvnn commentedChris, you are spot on w/ your assumptions. Popups is not a prerequisite, but I used it and it works pretty nicely for the node links on the Gmap tabs window.
Comment #21
mErilainen CreditAttribution: mErilainen commentedI tried to follow your instructions, but all I get is a blank page instead of map.
This is what I did:
My view is called map_user_living_in which I cloned to map_user_living_in_data, so $view_name = 'map_user_living_in_data';
Then I renamed the gmap_multiMarkers-View-Override_php.txt to gmap-view-gmap--map-user-living-in.tpl.php and did all the modifications to those parts required. Because we are doing the views override for the original view, not the cloned one right?
I used the Views Customfield module to find out the field names of the $views_result variable, but I'm not sure how can I find the right field names for the $result[] array. I tried for example $result['name'] = $view_result->users_name; to get the user's full name, instead of separate first name and last name.
Comment #22
FreddieK CreditAttribution: FreddieK commentedI whipped up some quick n' dirty code to get around this issue for my views. It doesn't show a cluster marker, but when opening up a marker that is on the same spot as others it will display all of them in the popup window. Should probably be worked in as a configurable option since you might not want this behavior all the time.
Comment #23
serhiyvk CreditAttribution: serhiyvk commentedHi, can you please tell, where would I put this code in order to use it in my views?
EDIT: I see now, this code is to be added in file sites/all/modules/gmap/gmap.views.inc
Just that now I have one issue: in popup for the marker, where there are two same locations, the link to node, which belongs to this marker appears twice.
Comment #24
petrios CreditAttribution: petrios commentedHi,
solution #22 is usable for me, BUT I have same trouble after adding in gmap.views.inc as serhiyvk - marker appears twice. Thanks you for any advice.
Comment #25
FreddieK CreditAttribution: FreddieK commented#23, #24
For me the usecase is that the links are to different nodes, even though they share the same adress. At that point the whole HTML block is generated in ['text'], so you should do some preg_replace() in php to erase links before adding the marker.
Here, that is:
Also, rather than putting the text in gmap.views.inc you should put it in template.php in your theme.
Comment #26
petrios CreditAttribution: petrios commentedFreddie, thx you for your answer, but I didn´t understand what should I do. Honestly, I have only little experience with PHP functions and I don´t know how use preg_replace() in this case and put in template.php. Could you give detailed description?
Thx a lot
Comment #27
Chadwick Wood CreditAttribution: Chadwick Wood commentedFreddieK, unfortunately the built-in definition of template_preprocess_gmap_view_gmap() calls theme('gmap'), which inserts the javascript for your map markers before yourtheme_preprocess_gmap_view_gmap() will get called. At least, that's what I'm seeing on my site. My solution to that (unfortunately a hack) is to go into gmap.views.inc in the module and comment out line 35 or so:
Also, in my case what I wanted instead was for duplicate locations to be "nudged" apart from each other, so here is a preprocess function that achieves that (based on FreddieK's code):
Comment #28
Exploratus CreditAttribution: Exploratus commentedI am trying to put in the code in Template and ina custon module, and i get:
Cannot redeclare template_preprocess_gmap_view_gmap
It seems since gmap declares it, i cant redeclare it. How did you guys get around this?
Comment #29
rooby CreditAttribution: rooby commentedThis is a duplicate of #284481: GMap Views - show distinct markers or links for places with same lat/long
I know there is some work in this issue but it is very old and wouldn't work with the latest version of gmap.
There is a more recent patch in the other issue and it is the older issue.
If you still prefer the approach done here (I haven't looked into what it actually does) please do an updated version and post it to the other issue.
Comment #30
mry4n CreditAttribution: mry4n commentedSubscribe
Comment #31
commonpike CreditAttribution: commonpike commented#27 did the trick, but i had to modify it quite a lot. I liked the approach though.
first, I needed to comment
at line 1400 in gmap.module (function template_preprocess_gmap_view_gmap).
this is a hack :-/
after that i could add #27 code to my themes template.php, but with some changes:
You may notice the changes at the bottom - a different version of GMap I guess.
I also changed the logic in nudging the markers, so they spiral outward from their original position (I had like 10 marker with the same lat/long :-))
$2c
*-pike
Comment #32
ikeigenwijs CreditAttribution: ikeigenwijs commentedIf everything else fails, i ll trie this hack,
But this looks also promising: http://drupal.org/node/1139088#comment-4961888
Comment #33
thtas CreditAttribution: thtas commentedI've worked around this with some simple module code using hook_gmap. no need to hack anything.
drupal 6.x
Comment #34
ikeigenwijs CreditAttribution: ikeigenwijs commented@ thtas
Can you explain what you did ?
You just made a custim module with this code? .module, .info
An did that the trick?
I use gmap for i while now, but due to an update i have the following problem:
Not all the nodes on the same location are beeing shown, apears to be limited to 2
thx a lot.
Comment #35
thtas CreditAttribution: thtas commentedYeah this code was part of a larger custom module, but at minimum it would just be a .module and .info file.
Not sure about the 2 item limit - have you checked the gmap view to make sure it's not paging or something?
Comment #36
ikeigenwijs CreditAttribution: ikeigenwijs commentedI found it, the locations with 3 or more all had an lat/long of 0.
Comment #37
jjbellamy CreditAttribution: jjbellamy commentedthtas,
After some research on the site for this issue, I like what you are proposing here. I have the same problem, showing multiple nodes with same latitude/longitude (city) on a single map. However, not sure how to implement your proposed codes. Should it be added to a module (gmap.module?) or as a new module? I am not a drupal programmer but can get around! Thanks a million for your help.
Comment #38
thtas CreditAttribution: thtas commented@jjbellamy,
You would need to have a custom module. e.g.
create a folder called jjbellamy, then inside create two files:
jjbellamy/jjbellamy.module
which contains the contents of the code in my post above, except with the word MYMODULE, replaced by jjbellamy,
AND
jjbellamy/jjbellamy.info
which contained the following:
Then upload and enabled your module.
for more info on how to create a custom module, see http://drupal.org/node/416986
Comment #39
jjbellamy CreditAttribution: jjbellamy commentedThanks a lot thtas. I was able to install both files into a custom sub-folder in all/module. I enabled the module. However, when I try to view my map I get an error message (same if I go to GMap settings). The message says
warning: Missing argument 2 for caidc_gmap() in /home/caidc/public_html/sites/all/modules/custom_caidc/caidc.module on line 2. I copied straight from this thread. is there something I do wrong? or need to customize the line (function caidc_gmap($op, &$map))?
Thanks for your help.
Comment #40
webservant316 CreditAttribution: webservant316 commentedsubscribe - need to fix this asap also.
Comment #41
jjbellamy CreditAttribution: jjbellamy commentedI finally was able to change the template file as per comment #51 at http://drupal.org/node/284481#comment-4997500. Good it works.
Comment #42
webservant316 CreditAttribution: webservant316 commentedHere is the solution I went with - http://drupal.org/node/1139088#comment-5956720. Works great for me.