Active
Project:
GMap Module
Version:
7.x-2.x-dev
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
12 Aug 2011 at 13:12 UTC
Updated:
23 Apr 2013 at 13:10 UTC
Hi everybody,
I need to setup different marker per every single location (node). Each of my node has integer number in a particular CCK field called Number and what I want is to have this number displayed in gmap marker, like this:
> http://cl.ly/2Y3T3J2B2X1M2w2d0u2n
Is that doable? How?
Just to be clear - the numbers dont go from 1 to n in sequence. There are ranges, for example, from 100 to 125, then a gap, and then from 200 to 264, gap, 300 to 311, etc... So I cant use the sequence feature of Gmap markers .ini file.
Thanks for any help.
Comments
Comment #1
johnvDid you find a solution already?
You can add the number to the list of fields, and show this field in the marker. Then, theme it as you like.
Comment #2
petiar commentedHi johnv,
yes, I got the solution which I am quite proud of. :-)
I have this callback function which return all locations on the map. It is actually a view containing title, latitude, longitude and that number. This view is json encoded and provided to .js script which displays google map. In this script I go through all locations and place it on the map and for each image marker I call small standalone script which generates number as a image using some php functions.
It would be even more elegant provide another callback function and return image generated by ImageCache module, but this works alright, so there was no reason to bother with that.
You can check the result on http://mpba.sk/en/mapa
Thanks for your interest.
Petiar.
Comment #3
johnvNice result,
would you mind to share your code, so others can use it as an example?
Comment #4
petiar commentedOk, no problem mate!
This is the jquery stuff. I took most of it from somewhere on Gmail API document pages, can't remember where exactly, unfortunately. Check the AJAX call at the end of initialize() function and subsequent setMarkers() function call.
In the AJAX call I am receiving list of locations from this function (which is the appropriate hook_menu's callback function):
As you can see I am literary getting appropriate view, taking the needed fields from it and print it as JSON what actually means that I am sending them back as an AJAX call result. Now back to the javascript file - look at the line bellow the *** getting marker image *** and you can see that I am getting an image from file. This file is not a image though, but very simple php script which generates one according the content of the "c" parameter. This is the script:
The cherry on the top is that this script actually does the caching - so if the image already exists in dedicated folder, it does not get generated again (unless the "f" (force generate) option is specified when calling the script).
I hope it'll help someone. :-)
Petiar
Comment #5
johnvNice work!
Let's keep this alive for future reference. (Not sure how, yet)
Perhaps via a link on the project page, or d.o. documentation pages.
(I guess this is in essence a version-proof solution)
Comment #6
petiar commentedIt depends if the function views_get_view_result() is the same in D7 version of VIews, that means as far as I know the Views 3. And if drupal_json() still exists. If that's the case then everything should be version-proof.
Comment #6.0
petiar commentedMore details added.