Hi,
I'm using joomla 2.5.11 with the Phoca Maps 2.0.6 module and plugin.
Since i like to have "control" over the markers, i'd like to use the overlay function setMap(map) (google maps API).
When i got it right, i need to have an javascript array of all the markers shown in the map.
Can i use markerArray.push(markerV) somehow after the marker is created via $map->setMarker(...) in the phocamaps.php file?
Please help!
Maps API Marker Overlay
- Jan
- Phoca Hero
- Posts: 48402
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact:
Re: Maps API Marker Overlay
Hi, no experiences with this feature, so yes, the php code needs to be customized but I am not able to say which part
Jan
Jan
If you find Phoca extensions useful, please support the project
-
- Phoca Newbie
- Posts: 2
- Joined: 22 Aug 2013, 14:48
Re: Maps API Marker Overlay
Hi again.
I've found a solution, so i post it here (maybe it's useful for someone with similar problems):
First, to define our javaScript array to store the markers in, just after
add the line
Now that we have our array, we can fill it by adding
right after
I guess it's not working if you have more than 1 map on your website, because "M1" stands for "Map One". So i case of multiple maps, this has to be more dynamic.
Because i wanted to use the overlay-function for displaying/hiding specific categories, i had to store the catid of each marker with it into the array.
To do so, i added the line
before i "pushed" the marker into the array.
Now you can loop through your markersArray and manipulate each marker's behavior.
For example:
to hide each marker with catid = 2.
I hope this was helpful, i'll add the URL to the website when it goes public, so you can see the result.
I've found a solution, so i post it here (maybe it's useful for someone with similar problems):
First, to define our javaScript array to store the markers in, just after
Code: Select all
$output .= $map->startJScData();
Code: Select all
$output .= "markersArray = []; \n";
Now that we have our array, we can fill it by adding
Code: Select all
$output .= "markersArray.push(markerPhocaMarker".$markerV->id."PlgPM1);\n";
Code: Select all
$map->setMarker($markerV->id,$markerV->title,$markerV->description,$markerV->latitude, $markerV->longitude, $iconOutput['icon'], $iconOutput['iconid'], $text, $markerV->contentwidth, $markerV->contentheight, $markerV->markerwindow, $iconOutput['iconshadow'], $iconOutput['iconshape']);
I guess it's not working if you have more than 1 map on your website, because "M1" stands for "Map One". So i case of multiple maps, this has to be more dynamic.
Because i wanted to use the overlay-function for displaying/hiding specific categories, i had to store the catid of each marker with it into the array.
To do so, i added the line
Code: Select all
$output .= "markerPhocaMarker".$markerV->id."PlgPM1.category=".$markerV->catid.";\n";
Now you can loop through your markersArray and manipulate each marker's behavior.
For example:
Code: Select all
var category = 2;
for (var i = 0; i < markersArray.length; i++ ) {
if(markersArray[i].category == category){
markersArray[i].setMap(null);
}
}
I hope this was helpful, i'll add the URL to the website when it goes public, so you can see the result.