terikon / marker-animate-unobtrusive

Google Maps markers become animated, unobtrusively

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Marker disappears in my Pusher integration

colingoldberg opened this issue · comments

This may not be a bug in your code, but maybe you can see something that I don't.

I want to integrate a mashup with Pusher, so that external (Pusher) messages can result in a marker moving to a new location, as dictated by the location data in the message. Publishing a message to the page results in the marker disappearing.

As a test, I modified the makermove-sliding.html demo by adding the following:

...
[script src="http://js.pusher.com/3.0/pusher.min.js" type="text/javascript"][/script]
...
var positionToGoogleLatLng = function(position) {
return new google.maps.LatLng(position.lat,position.lng);
};

-- In initialize()
var myLatlng = new google.maps.LatLng(40.63,-73.90);
...
var pusher = new Pusher('[Account ID]');
var channel = pusher.subscribe('[ChannelName]');
channel.bind('[TopicName]', function(data) {
var duration = parseInt($('#durationOption').val());

if (duration < 0) {
duration = 1;
$('#durationOption').val(duration);
}

marker.setDuration(duration);
marker.setEasing($('#easingOption').val());
marker.setPosition(positionToGoogleLatLng(data.location.lat,data.location.lng));
});
...

-- No other changes were made.

Running the following nodejs script (on my laptop):

var Pusher = require( 'pusher' );
var pusher = new Pusher({ appId: '[Acct#]', key: '[Account ID]', secret: '[Secret]' });
pusher.trigger( '[ChannelName]', '[TopicName]', { id: '4', location: {lat: 40.646, lng: -73.94} } );

  • the marker disappears.

Am I doing something wrong? Can you help?

Colin Goldberg

Oops, I saw a mistake in my code - please ignore (it does work).

You welcome :)