link in Google Maps marker - google-maps-markers

I cannot get a link to work in my marker.
My code is:
var marker = new google.maps.Marker({ draggable: false, raiseOnDrag: false, icon: image, shape: shape, map: map, url: 'http://www.google.com/', position: myLatlng36, title:"My marker" });
It shows the marker perfectly on the right location, but nothing happens when I click it.
I also tried adding
google.maps.event.addListener(marker, 'click', function() {
window.location.href = marker.url;
});
No result.
Any suggestions?

Did you test with?
google.maps.event.addListener(marker, 'click', function() {
window.location.href = this.url;
});
Changing 'marker' to 'this'?

Related

Mootools Add click event with Drag.Cart

I use this example under jsfiddle.net, to build a drag&drop system and if I create a click event on shirts images (draggables), this event doesn't work.
How to combine drag and click events to the draggables elements with Mootools?
window.addEvent('domready', function(){
$$('.item').addEvent('mousedown', function(event){
//event.stop();
// `this` refers to the element with the .item class
var shirt = this;
var clone = shirt.clone().setStyles(shirt.getCoordinates()).setStyles({
opacity: 0.7,
position: 'absolute'
}).inject(document.body);
var drag = new Drag.Move(clone, {
droppables: $('cart'),
onDrop: function(dragging, cart){
dragging.destroy();
if (cart != null){
shirt.clone().inject(cart);
cart.highlight('#7389AE', '#FFF');
}
},
onEnter: function(dragging, cart){
cart.tween('background-color', '#98B5C1');
},
onLeave: function(dragging, cart){
cart.tween('background-color', '#FFF');
},
onCancel: function(dragging){
dragging.destroy();
}
});
drag.start(event);
});
// This doesn't work
$$('.item').addEvent('click', function(event){
console.log('click');
});
});
the event.stop(); will preventDefault and stopPropagation so the mousedown won't bubble into click.
furthermore, it clones and applies stuff to a new element and somewheere along the lines, mootools-more will stop the event once again.
so replace the event.stop with this.fireEvent('click', event); to bubble it up manually - though strictly speaking, a click is on mouseup and you kind of need to wait for that instead.
http://jsfiddle.net/dimitar/qsjj1jpe/4/

Ajax Request with Googlemap API

I'm building a page that will display a Googlemap with markers. Since I have about 50000 markers, I decided not to load them all at once.
Therefore I tried building an JSON request to my server (see code below) but here is my problem:
When I use the code as it is presented here, the Map is blank (no Map shows up).
When I remove the $.ajax and leave the function getMarkers emtpy, the map shows properly (whitout marker of course).
Can anyone tell me what I'm doing wrong please?!
Thank you!
(If that is any help, I'm using Django)
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
function init_map() {
var mapOptions = {
center: new google.maps.LatLng(48.853,2.35),
zoom: 6,
streetViewControl: false,
};
var myMap = new google.maps.Map(document.getElementById("map-container"),mapOptions);
var infowindow = new google.maps.InfoWindow();
google.maps.event.addListener(myMap, 'idle', getMarkers);
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
initialLocation = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
map.setCenter(initialLocation);
});
}
}
google.maps.event.addDomListener(window, 'load', init_map);
function getMarkers() {
$.ajax({
type: 'POST',
url: {%url 'pointslink'%},
async: "true",
dataType: "json",
contentType: 'application/json',
data: JSON.stringify(
coords: myMap.getBounds(),
zoom: myMmap.getZoom()
),
success: updateMarkers
});
}
function updateMarkers(data) {
{% for city in data %}
var pos = new google.maps.LatLng({{city.latitude}},{{city.longitude}});
var marker = new google.maps.Marker({
position: pos,
map: myMap,
title:'{{city.name}}'
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent('Name: {{city.name}}<br/>Population: {{city.population}}');
infowindow.open(myMap, this);
});
{%endfor%}
}
</script>

adding event to image in EaselJS

I was hoping that I could get a little help with something I'm trying to do. I'm learning EaselJS, Extjs but still a little new. I'm trying to create an extJS window, inside the window I added a canvas which I use easelJS to manipulate. On a button1 I added an event handler that will overlay an image... what I am trying to do is make that overlayed image have events. In the long run I'd like to be able to highlight that image, and store the number of overlayed images from mouseclick onto that image.
here is my code
var stage;
var overlay;
var overImage;
var myImage;
var bgrd;
Ext.onDocumentReady( function () {
//var myImage = new createjs.Bitmap("dbz.jpg");
//stage.addChild(myImage);
//stage.update();
function setBG(){
myImage = new Image();
myImage.src = "dbz.jpg";
bg();
}
function bg(){
bgrd = new createjs.Bitmap(myImage);
stage.addChild(bgrd);
stage.update();
}
Ext.define('EaselWindow', {
width: 1000,
height: 750,
extend: 'Ext.Window',
html: '<canvas id="demoCanvas" width="1000" height="750">'
+ 'alternate content'
+ '</canvas>',
afterRender: function() {
this.callParent(arguments);
stage = new createjs.Stage("demoCanvas");
stage.onload = setBG();
}, // end after render func
listeners: {
click: {
element: 'body',
fn: function(){
var seed = new createjs.Bitmap("seed.jpg");
seed.alpha = 0.5;
seed.x = stage.mouseX-10 ;
seed.y = stage.mouseY-10 ;
stage.addChild(seed);
stage.update();
} //end addeventlistener
}
},
items:[{
itemId: 'button1',
xtype: 'button',
text: 'click the button',
visible: true,
enableToggle: true,
toggleHandler:
function(button, pressed){
if(button.pressed==true){
overImage = new Image();
overImage.src = "stuff.jpg";
overlay = new createjs.Bitmap(overImage);
stage.addChild(overlay);
stage.update();
}
else
{stage.removeChild(overlay);
stage.update();
}
}// end func
},{
itemId: 'button2',
xtype: 'button',
text: 'button2'
}]
}); // end define
Ext.create('EaselWindow', {
title: "Ext+Easel",
autoShow: true,
}); //end easelwindow
overImage.addEventListener("mouseover", function(){
overlay.alpha=0.7;
}); // this function isn't working
});
edit to add: itemId: 'button2',
xtype: 'button',
text: 'addSeed',
enableToggle: true,
handler: function(button, pressed){
if(button.pressed==true){
bgrd.addEventListener('click', function(){
seed = new createjs.Bitmap("seed.jpg");
seed.alpha = 0.5;
seed.x = stage.mouseX-10 ;
seed.y = stage.mouseY-10 ;
storex= seed.x;
storey= seed.y;
console.log(storex +","+ storey);
stage.addChild(seed);
stage.update();
})
}
} //end addeventlistener
but but once the button is pressed the ability to click remains on if w/ the if statement condition I don't understand why, is there a way to say else ( turn off)
You can add EventListeners in EaselJS as follows:
function bg(){
bgrd = new createjs.Bitmap(myImage);
bgrd.addEventListener('click', onClick);
stage.addChild(bgrd);
stage.update();
}
function onClick() {
console.log('bgrd was clicked.');
}
This is btw. very well documented in the EaselJS-docs: http://www.createjs.com/Docs/EaselJS/classes/EventDispatcher.html and there are tons of examples for this and most other cases you are looking for on Github at:
https://github.com/CreateJS/EaselJS/tree/master/examples
and
https://github.com/CreateJS/sandbox

Ext Js Tooltip to stay when hover over

I have a button at which when the user hovers over I display a tooltip.
function createTooltp(toolTipId) {
tooTip = new Ext.ToolTip({
target: toolTipId, //The button
anchor: 'left',
autoWidth: true,
autoHeight: true,
closable: false,
autoHide: true,
autoHeight : true,
closable: false,
contentEl: 'content-tip'
});
tooTip.show();
}
Now when the user hovers away obviously it would hide since I mentioned autoHide:true,.
But when the user hovers to the actual tooltip which is displayed. I want that tooltip to be there till the mouse is on top of it and hide when the mouse is not on the target(button) or on the actual tooltip. How could this be achieved?
Don't rely on Ext to hide the tooltip for you (autoHide: false). Instead, start a delayed hide using window.setTimeout when you leave the tooltip target and when you leave the tooltip, but cancel the hide if you hover back over the tooltip. That way, it will only hide when you're not on the tooltip after 500ms.
var toolTip = Ext.create('Ext.tip.ToolTip', {
target: targetId,
html: 'ToolTip',
anchor: 'left',
dismissDelay: 0,
showDelay: 0,
autoHide: false
});
toolTip.on('show', function(){
var timeout;
toolTip.getEl().on('mouseout', function(){
timeout = window.setTimeout(function(){
toolTip.hide();
}, 500);
});
toolTip.getEl().on('mouseover', function(){
window.clearTimeout(timeout);
});
Ext.get(targetId).on('mouseover', function(){
window.clearTimeout(timeout);
});
Ext.get(targetId).on('mouseout', function(){
timeout = window.setTimeout(function(){
toolTip.hide();
}, 500);
});
});
My two cents: I had task to add same behavior for tooltips inside grid panel columns, and it doesn't have way to pass config or tooltips inside it (or maybe I missed it in the docs and while reading sources, please comment if I had). So I solved it by adding small override to my app
Ext.define('App.overrides.ToolTip', {
override: 'Ext.tip.ToolTip',
dismissDelay: 0
});
Try this:
function createTooltp(toolTipId) {
var tooTip = new Ext.ToolTip({
target: toolTipId, // The button
anchor: 'left',
showDelay: 0,
hideDelay: 0,
trackMouse: true
});
tooTip.show();
}
Learn more from this reference: ToolTip
I did it with a work around (jQuery). And used Span and CSS to create my own tooltip.

Mootools 1.3 Fx.Morph 'opacity' not working in IE8

http://jsfiddle.net/hL6rT/1/
I've created div with a absolute positioned image inside it the idea is to fade the image in and out like a pulse. All went well until IE8 showed up.
See the link for code. Works fine in FF, that is to say the div fades in and out in a continuous loop. But in IE8 it fades in and out once and then stops.
Works fine in FF & IE8 with mootools 1.2.5, but not 1.3 or 1.3 Compatibility Mode.
For some bizarre reason if the alert after 'fadeIn' is included in the onComplete the function will display the alert and the second alert in the 'fadeOut' onComplete, but still NOT fade the div.
Help?
it is probably easier to do just the tween on the element via the oncomplete to make a blink effect:
http://jsfiddle.net/hL6rT/2/
var fadeImg = document.id('lucy');
fadeImg.set("tween", {
duration: 2000,
transition: Fx.Transitions.Quint.easeIn,
onComplete: function() {
this.element.fade(this.element.getStyle("opacity") == 0 ? 1 : 0);
}
}).fade(0);
// how you can cancel it
document.id("stop").addEvent("click", function(e) {
e.stop();
fadeImg.get("tween").cancel(); // this cancels it.
});
to fix your version:
http://jsfiddle.net/hL6rT/4/
works fine if you set the initial value of opacity to 0
var fadeImg = document.id('lucy').setStyle("opacity", 0);
var fadeIn = function() {
var inDiv = new Fx.Morph(fadeImg, {
link: 'cancel',
duration: 2000,
transition: Fx.Transitions.Quint.easeIn,
onComplete: function() {
fadeOut();
//alert('FadeIn Complete');
}
}).start({
'opacity': ['0', '1']
});
};
var fadeOut = function() {
var outDiv = new Fx.Morph(fadeImg, {
link: 'cancel',
duration: 2000,
transition: Fx.Transitions.Quint.easeOut,
onComplete: function() {
fadeIn();
//alert(FadeOut Complete!');
}
}).start({
'opacity': ['1', '0']
});
};
fadeIn();
update IE does not seem to consistently like this particular transition being chained. you may need to remove it and use the default one.

Resources