terikon / marker-animate-unobtrusive

Google Maps markers become animated, unobtrusively
MIT License
222 stars 52 forks source link

Marker disappears in my Pusher integration #7

Closed colingoldberg closed 8 years ago

colingoldberg commented 8 years ago

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} } );

Am I doing something wrong? Can you help?

Colin Goldberg

colingoldberg commented 8 years ago

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

viskin commented 8 years ago

You welcome :)