Kyle Hotchkiss
Kyle Hotchkiss

Reputation: 11112

Mapbox.js tooltips - position over marker, but don't follow mouse

Is there a way to get Mapbox.js tooltips to show when you're hovering over a marker without following the mouse around? I just want it to stay put when I hover.

I am using the following code on my map:

var map = L.map("impact-map")
    .setView([20, 80], 3)
    .addLayer(L.mapbox.tileLayer("hotchkissmade.in_impact", {
        detectRetina: true
    }));

var myGridLayer = L.mapbox.gridLayer('hotchkissmade.in_impact').addTo( map );
var myGridControl = L.mapbox.gridControl(myGridLayer, { 
    follow: true
}).addTo( map );

I am using the follow:true from the example here.

Disclaimer: I know there may be more flexibility outside of gridControl but I like having my tooltips from Tilemill as I don't want to load the data in the browser twice, since I'm basing the tooltip data off the layer making the markers on my map in Tilemill

Upvotes: 0

Views: 932

Answers (1)

tmcw
tmcw

Reputation: 11882

This isn't possible with a gridControl - you can have tooltips either follow the mouse or stay in a specific location, but unlike L.mapbox.featureLayer, there is no actual marker, polygon, or feature you're hovering over - the geometry is not pushed to the client - so, there would be no 'anchor' for the tooltip to stay on.

Upvotes: 1

Related Questions