I use LocationResources and it works great on the subresources. I use a customized icon.
But when i call it on the parent resource with it will show the default Google Maps icon.
This is my call:
[[locationResourcesMap? &parents=123
&js=locationScript
]]
ModX: 2.7.1
PHP: 7.1
Hi!
Hmmm are you getting any errors in your browser console?
Can you show the custom js script you’re using?
I have no errors in the console. Here is my custom js, which is ignored on the parent resource:
<script>
var lrMap[[+lr.docid]] = new google.maps.Map(document.getElementById('[[++locationresources.map_div]][[+lr.docid]]'), {
zoom: [[+lr.zoom_lvl]],
center: {lat: [[+lr.map_lat]], lng: [[+lr.map_lng]]}
});
if ([[+lr.has_marker]]) {
var marker = new google.maps.Marker({
position: {lat: [[+lr.marker_lat]], lng: [[+lr.marker_lng]]},
draggable: false,
clickable: true,
map: lrMap[[+lr.docid]],
icon: 'assets/img/diamant-ico.png'
});
var lrTitle = '[[+lr.marker_title]]';
var lrDesc = '[[+lr.marker_desc]]';
var lrLink = '[[+lr.marker_link]]';
var lrContent = '';
if (lrTitle.length > 0) {
lrContent += "<h4>[[+lr.marker_title]]</h4>";
}
if (lrDesc.length > 0) {
lrContent += "<p>[[+lr.marker_desc]]</p>";
}
if (lrLink.length > 0) {
lrContent += "<a href='[[+lr.marker_link]]'>Detail</a>";
}
if (lrContent.length > 0) {
marker.info = new google.maps.InfoWindow({
content: lrContent
});
marker.info.open(lrMap[[+lr.docid]], marker);
google.maps.event.addListener(marker, 'click', function() {
marker.info.open(lrMap[[+lr.docid]], marker);
});
}
}
[[+lr.cluster_markers]]
google.maps.event.addDomListener(window, "resize", function() {
var center = lrMap[[+lr.docid]].getCenter();
google.maps.event.trigger(lrMap[[+lr.docid]], "resize");
lrMap[[+lr.docid]].setCenter(center);
});
</script>
My snippet call on the parent resource is:
[[locationResourcesMap? &parents=
[[*id]]&js=
locationScript]]
Hi,
I had a look back at the code:
<?php
/**
* The main LocationResources service class.
*
* @package locationresources
*/
class LocationResources {
public $modx = null;
public $namespace = 'locationresources';
public $cache = null;
public $options = array();
public $profile = null;
public $clusterMap = 0;
public function __construct(modX &$modx, array $options = array()) {
$this->modx =& $modx;
$this->namespace = $this->getOption('namespace', $options, 'locationresources');
$corePath = $this->getOption('core_path', $options, $this->modx->getOption('core_path', null, MODX_CORE_PATH) . 'components/locationresources/');
This file has been truncated. show original
The reason this is happening is because it uses Google’s marker clusterer script to handle multiple markers. So in it’s current state I don’t think what you’re trying to do is possible.
It could be a good enhancement to add an option to the Extra that allows you to not use clustering though!
I’ll happily accept any PRs if someone has the time to add it!
Thank you!
I hope it works in the next update