I'm trying to replace the icons with a RichMarker as seen here: https://google-maps-utility-library-v3.googlecode.com/svn/trunk/richmarker/examples/richmarker.html
Here's the following code I'm using:
marker: {
values: [
{foreach $items as $item}
{
latLng: [{ifset $item->optionsDir['gpsLatitude']}{!$item->optionsDir['gpsLatitude']}{else}0{/ifset},{ifset $item->optionsDir['gpsLongitude']}{!$item->optionsDir['gpsLongitude']}{else}0{/ifset}],
content: "<div class='cluster-bg'><div class='cluster'><span>1</span></div></div>",
data: '<div class="marker-holder"><div class="marker-content{ifset $item->thumbnailDir} with-image"><img src="{thumbnailResize $item->thumbnailDir, w => 120, h => 160}" alt="">{else}">{/ifset}<div class="map-item-info"><div class="title">'+{ifset $item->post_title}{$item->post_title}+{/ifset}'</div>{if $item->rating}<div class="rating">{for $i=1; $i <= $item->rating["max"]; $i++}<div class="star{if $i <= $item->rating["val"]} active{/if}"></div>{/for}</div>{/if}<div class="address">'+{ifset $item->optionsDir["address"]}{$item->optionsDir["address"]|nl2br}+{/ifset}'</div>' + {__ 'VIEW MORE'} + '</div><div class="arrow"></div><div class="close"></div></div></div></div>'
}
{if !($iterator->last)},{/if}
{/foreach}
],
I understand how to add a rich marker to a single marker, but here I'm dynamically creating markers under "values." I have no idea where to add the:
= new RichMarker ({
Is this possible with these two plugins or should I look elsewhere?
Thanks
Here is the code that you must add:
jQuery("YOUR_SELECT").gmap3({
defaults:{
classes:{
Marker:RichMarker
}
},
map:{
options: {
zoom: 11,
},
marker: {
options: {
content: '<div>ADD your Custom HTML code</div>',
}
}
})
Related
I am looking for an example where I can specify template for rendering options, so that I can render an option as a two part: span with a background color and a value.
Simillar to this https://jqueryui.com/selectmenu/#custom_render
is this supported in the jsviews tag implementation?
Many thanks.
There are probably other approaches, including making your own custom tag - not using jQuery UI, or creating a derived version of the {{selectmenu}} tag control here, {{myselectmenu}} (using baseTag).
But here is a quick suggestion of one way you can do it:
{^{selectmenu person name="person" onBind=~onbind}}
{^{for people}}
<option data-style="{{:style}}" value="{{:id}}">{{:name}}</option>
{{/for}}
{{/selectmenu}}
Data:
people: [
{name: "John Resig", id: "1", style: "background-image: url(...);"},
...
Code:
pageTmpl.link("#page", model, {
onbind: function(val) {
// override onBind for this tag control instance
this.baseApply(arguments);
// override _renderItem for this widget instance:
this.widget._renderItem = function( ul, item ) {
var li = $( "<li>" ),
wrapper = $( "<div>", { text: item.label } );
if ( item.disabled ) {
li.addClass( "ui-state-disabled" );
}
$( "<span>", {
style: item.element.attr( "data-style" ),
"class": "ui-icon " + item.element.attr( "data-class" )
})
.appendTo( wrapper );
return li.append( wrapper ).appendTo( ul );
};
}
});
On a map with 300+ markers, each with their own info box & imagery & data, loading the entire map & all the markers at once causes page speed issues.
here's an example - www.naturesoundmap.com/listing-type/nature-soundscape
What I would like to do is: Have the markers served dynamically based on a starting location & pre-determined zoom level.
See the above link for an example starting location - in this case I want the map to only load the 20 or so markers viewable on screen, not the 300+ markers from the entire planet. As the user scrolls to new areas of the map, new markers should load dynamically as their location comes into view.
I am using a Wordpress theme 'Explorable' by Elegant Themes so the following code is already a part of the theme.
As simple an explanation as possible would be much appreciated as I am a novice!
Thanks
Marc
Currently, this is the code I have (this is an excerpt - let me know if you need to see the entire file)
mapTypeId: google.maps.MapTypeId.<?php echo esc_js( strtoupper( et_get_option( 'explorable_map_type', 'Roadmap' ) ) ); ?>,
zoomControl: true,
zoomControlOptions: {
position : google.maps.ControlPosition.LEFT_BOTTOM,
style : google.maps.ZoomControlStyle.LARGE},
panControl: false,
streetViewControlOptions: {},
overviewMapControl: false,
overviewMapControlOptions: {
opened : false
},
scrollwheel: true,
streetViewControl: false,
mapTypeControl: false,
mapTypeControlOptions: {}
}
}
});
function et_add_marker( marker_order, marker_lat, marker_lng, marker_description ){
var marker_id = 'et_marker_' + marker_order;
$et_main_map.gmap3({
marker : {
id : marker_id,
latLng : [marker_lat, marker_lng],
options: {
icon : "<?php echo get_template_directory_uri(); ?>/images/red-marker.png"
},
events : {
click: function( marker ){
if ( et_active_marker ){
et_active_marker.setAnimation( null );
et_active_marker.setIcon( '<?php echo get_template_directory_uri(); ?>/images/red-marker.png' );
}
et_active_marker = marker;
marker.setAnimation(google.maps.Animation.BOUNCE);
setTimeout(function(){ marker.setAnimation(null); }, 3750);
marker.setIcon( '<?php echo get_template_directory_uri(); ?>/images/blue-marker.png' );
$(this).gmap3("get").panTo( marker.position );
$.fn.et_simple_slider.external_move_to( marker_order );
},
mouseover: function( marker ){
$( '#' + marker_id ).css( { 'display' : 'block', 'opacity' : 0 } ).stop(true,true).animate( { bottom : '15px', opacity : 1 }, 500 );
},
mouseout: function( marker ){
$( '#' + marker_id ).stop(true,true).animate( { bottom : '50px', opacity : 0 }, 500, function() {
$(this).css( { 'display' : 'none' } );
} );
}
}
},
overlay : {
latLng : [marker_lat, marker_lng],
options : {
content : marker_description,
offset : {
y:-42,
x:-122
}
}
}
});
}
It looks like you're calling et_add_marker() each time for the 320 or so points. Perhaps if you can figure out a way to load the point data in a KML file and iterate through each item that would boost speed?
How are the data points managed - in Wordpress as a custom post, or are you hard coding them into your theme?
I have two grids side by side.
The left grid has a list of tags the user can select, and the grid on the right is empty so the user can drag the tags he wants there.
The plugin code for both grids is:
viewConfig: {
plugins: [
Ext.create('Ext.grid.plugin.DragDrop', {
ddGroup: 'selectedTags'
})
]
}
So, as I wanted to limit the user to be able to drag only 5 tags, I've added the following code to the grid on the right:
listeners: {
beforedrop: {
fn: function() {
if (grid.getStore().data.items.length > 4) {
dropHandlers.cancelDrop();
}
},
scope: me
}
}
This is working perfectly but what I wanted is to show the NO-DROP icon when the items are dragged over the grid instead of showing the green line as if the action was allowed.
Thanks,
After looking for this solution for a while, I finally figured it out.
You must add two methods to the dropZone in the Target Grid:
notifyOver and onNodeDrop
The solution for my problem would be the code below:
Ext.create('Ext.grid.Panel', {
store: myStore,
columns: [columns],
viewConfig: {
plugins: {
ptype: 'gridviewdragdrop',
dragText: 'Drag and drop to reorganize',
pluginId : 'dragNdrop',
dropZone:{
notifyOver:function(source, e, data){
var store = this.view.ownerCt.getStore();
return store.getCount()<5?this.dropAllowed:this.dropNotAllowed
},
onNodeDrop:function(targetNode,dragZone,e,data){
var sourceStore = dragZone.view.ownerCt.getStore(),
targetStore = this.view.ownerCt.getStore(),
isDropValid = targetStore.getCount()<5;
if(isDropValid){
sourceStore.remove(data.records[0])
targetStore.add(data.records[0]);
}
return isDropValid;
}
}
}
},
height: 200,
width: 400,
renderTo: Ext.getBody()
});
Lopes, you can use column renderer in grid where you can check the items count and display appropriate icon. Code snippet for your reference:
gridCheckboxRenderer: function(value, meta, rec, rowInd, colInd, store){
var cssPrefix = Ext.baseCSSPrefix, cls = [cssPrefix + 'grid-checkheader'];
if (condition == false) {
cls.push(cssPrefix + 'grid-checkheader-checked-disabled');
return '<div class="' + cls.join(' ') + '"> </div>';
}
return '<div class="x-grid-row-checker"> </div>';
}
Hope it helps.
When you use the Ext.dataview.List in Sencha, it automatically inserts a nice loading spinner while the data is loading. That's all fine and dandy, but I'd like to know how to use a custom loader .gif.
I've looked around and think I need to change the loadmask but not positive cause I'm new to this. See this link.
Below is the code for one of my Lists. I'm hoping to be able to add the code suggested to one place so that all lists are affected and have the new spinner.
{
xtype: 'list',
height: '',
id: 'categoryList',
itemId: '',
width: '100%',
scrollable: false,
emptyText: '<div class="pdtsListHtml" style="margin-top:30%">Product List Empty</div>',
itemTpl: [
'<div ><div class="pdtsListHtml" style="display:inline;">{navigationElementItemName} ({navigationElementItemRecordCounts})</div><div style="display:inline;float:right;margin-right:5px;"><img src="resources/image/arrow.png" width="11" height="11"></div></div>'
],
store: 'productListStore',
allowDeselect: true,
onItemDisclosure: false
}
Here's a fiddle that shows you an example list with a loading mask that uses a gif.
Basically you should define your own Ext.LoadMask subclass and use it on the list:
Ext.define("Test.MyLoadMask", {
extend: "Ext.LoadMask",
alias: "widget.myloadmask",
getTemplate: function() {
var prefix = Ext.baseCSSPrefix;
return [
{
reference: 'innerElement',
cls: prefix + 'mask-inner',
children: [
{
reference: 'indicatorElement',
cls: prefix + 'loading-spinner-outer',
children: [
{ tag: 'img', src: "http://example.com/my-spinner.gif" }
]
},
{
reference: 'messageElement'
}
]
}
];
}
});
Then you should define an applyMasked on your lists that modifies the xtype and sets it to myloadmask instead of loadmask.
Using GMAP3 Google Map API 3 class. Cannot quite figure out how to trigger the click event on a marker from an external link via javascript. I have tried the v3 api syntax but suspect that I am missing something in relation to the GMAP3 library. Could anyone help me out here?
I am showing a map with markers and infobox data from an ajax request with a resulting JSON array. Works great. I assign a click event to the marker and it works fine. I am using parsing that same JSON array to populate a datatable with a Click Me
X is actually the incrementing marker counter I used when building the JSON array, so it would start with 0 and build to whatever value represents all my markers. I am expecting to use this value to tell GMAP3 which marker I want to pass the click event to... if this though process is wrong then I am really confused.
My JSON array object is stored in markerlist and passed to the function below... which works great but I cannot seem to trigger those clicks from my datatable links... (see my jquery code below to grab those clicks and attempt to pass them along to the map)
My map code is:
function display( markerlist ) {
$("#map").gmap3({action:'clear'});
$("#map").gmap3(
{action: 'init',
options:{
center:true,
zoom:13,
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: true,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
},
navigationControl: true,
scrollwheel: true,
streetViewControl: true
}
},
{action: 'addMarkers',
radius:100,
markers: markerlist,
clusters:{
maxZoom: 10,
// This style will be used for clusters with more than 0 markers
20: {
content: '<div class="cluster cluster-1">CLUSTER_COUNT</div>',
width: 53,
height: 52
},
// This style will be used for clusters with more than 20 markers
50: {
content: '<div class="cluster cluster-2">CLUSTER_COUNT</div>',
width: 56,
height: 55
},
// This style will be used for clusters with more than 50 markers
100: {
content: '<div class="cluster cluster-3">CLUSTER_COUNT</div>',
width: 66,
height: 65
}
},
marker: {
options: {
clickable: true
},
events:{
click: function(marker,event,data) {
$(this).gmap3({action: 'clear', name : 'infowindow'});
$(this).gmap3({action: 'addinfowindow', anchor: marker, options: { content:
'<div class="text"><strong><div style="color:navy;">' + data.itype + '</strong><br/><div id="address" snum="' + data.streetnum + '" snam="' + data.streetnam + '" styp="' + data.streettyp + '">'+ data.iaddress +'</div><br/>' + data.inum + '<br/>'+ data.datetime +'</div><hr>'+data.notes+'</div>'} })
},
mouseover: function(marker, event, data){
$(this).gmap3(
{ action:'clear', name:'overlay'},
{ action:'addOverlay',
latLng: marker.getPosition(),
content: '<div class="infobulle">' +
'<div class="bg"></div>' +
'<div class="text">' + data.itype +'</div>' +
'</div>' +
'<div class="arrow"></div>',
offset: {
x:-46,
y:-73
}
});
},
mouseout: function(){
$(this).gmap3({action:'clear', name:'overlay'});
}
}, //end events
callback: function(result){
if (result){
//not doing anything with a callback at this time
} else {
alert('Bad callback...');
}
} //end callbacks
} // end marker
}
,{action:"autofit"} //end action
);
$("a#link").live('click',function(markerlist){ // this works and I can get my arid ok, but the trigger won't work
var arid = $(this).attr('arid');
google.maps.event.trigger(markerlist[arid], 'click');
return false;
});
};
Any help would really be appreciated and am sure will be useful to others!
I think the problem is markerlist is not a global variable, it's local to your display function? What do you get if you write markerlist to the console in your click event handler?