i am trying to implement a simple "zoom to this point" link within a CartoDB infowindow. To do this i figure i need:

  1. To be able to place a script within an infowindow (mustache) template, so that the zoom link can be dynamically set
  2. Access to the lat/lng value that was clicked

Its not clear to me whether the JS should be placed within the mustache template (nested tags seem a bit messy), or elsewhere - something like an "infowindow.complete" event would be ideal, but not sure if that exists.

Currently i have

<script type="infowindow/html" id="infowindow_template2">
  <div class="cartodb-popup v2">
    <a href="#close" class="cartodb-popup-close-button close">x</a>
    <div class="cartodb-popup-content-wrapper">
      <div class="cartodb-popup-content">
        <strong>Route {{content.data.routenumber}}</strong>
        <p><a href="" id="infowindow-zoom-link">Zoom in here</a></p>
  <script type="text/javascript">
      // perform zoom based on lat/lng clicked
      // ...

My script does run, but i dont know how to access the lat/lng point. Is the information available within content.data? How can i debug what is in {{content}} ?

This post seems to provide an answer (ie use the 'featureClick' event, which has the lat/lng passed in), however the code doesn't fire for me - presumably because the content in the infowindow is not completed yet (hence my suggestion above)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.