Styled maps

Home Forums MapPress Support Styled maps

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #17892
    joew
    Participant

    Did the ability to style maps for MapBox or Leaflet ever exist or is that only if using Google Maps? I can’t find the location in my mappress installation to past json code.

    #17898
    Chris
    Keymaster

    Hi,

    The plugin supports MapBox Studio styled maps for Leaflet (as well as Google styled maps). But you need to use the latest MapPress (2.49.7) and create a PHP filter.

    I’ll write this up more fully in the documentation, but here’s an overview.

    MapBox Studio is here:
    https://www.mapbox.com/studio/styles/

    After you make your Studio style, get its URL:
    1) Click the menu next to the style, select ‘share, develop and use’
    2) Scroll down to ‘develop with this style’
    3) Go to the ‘leaflet’ tab. Copy that URL

    Now edit your theme’s functions.php file and create a filter to add the new style. Replace with the URL from step 3 above:

    <?php
    function mystyles($baselayers) {
      $baselayers[] = array(
        'provider' => 'mapbox-studio',
        'id' => 'mystyle',
        'name' => 'mystyle',
        'label' => __('My style'),
        'url' => '<YOUR URL GOES HERE>'
      );	
      return $baselayers;
    }
    
    add_filter('mappress_baselayers', 'mystyles');

    #18285
    jaycollier
    Participant

    Hi, Chris-

     

    Have these instructions changed? Or perhaps my understanding is weak 🙂

    Under Map Box > Use, I do not see “Develop with this style” or “Leaflet” options.

    I did try using the third party URL in the functions.php script (sample below) and changed my shortcode to include “mystyle”, but it did not make a difference on the map.

    https://api.mapbox.com/styles/v1/%5Bsnip%5D/cjhwbg4m613ho2rpn24azrqt9.html?title=true&access_token=%5Bsnip%5D/-68.873966/330

    [mashup query="preserve_region=southern maine" width="100%" zoom="11" style="mystyle"]

     

    #18286
    jaycollier
    Participant

    Can’t see how to edit, so here’s the shortcode on 2 lines.

    [mashup query="preserve_region=southern maine" 
    width="100%" zoom="11" style="mystyle"]
    #18288
    Chris
    Keymaster

    Hi,

    The instructions have changed: the ability to specify custom styles is now part of the MapPress settings screen.  Have you looked at the docs section for this already?

    https://mappresspro.com/mappress-documentation/#toc-mapbox-studio-styles

     

    #18289
    jaycollier
    Participant

    Yes, thank you. I did see those instructions. However, I am using automatic Leaflet maps generated from custom fields and mashups, and those instructions appeared to apply to the manual editor options: “The new style will appear as a selection in the layers control in the MapPress editor.”

    I am looking for a way to apply the MapBox style automatically to all maps (or via shortcode, which brought me to that outdated help thread.

    By the way, I did add the share URL to the MapBox Settings (“Styled Maps”) screen, giving it a name of “preserves1″ and used it in my mashup shortcode, but that didn’t change the styling either.
    <pre class=”prettyprint prettyprinted”><span class=”pun”>[</span><span class=”pln”>mashup query</span><span class=”pun”>=</span><span class=”str”>”preserve_region=southern maine”</span><span class=”pln”>
    width</span><span class=”pun”>=</span><span class=”str”>”100%”</span><span class=”pln”> zoom</span><span class=”pun”>=</span><span class=”str”>”11″</span><span class=”pln”> style</span><span class=”pun”>=</span><span class=”str”>”preserves1″</span><span class=”pun”>]
    </span>
    <p class=”prettyprint prettyprinted”><span class=”pun”>I also checked to make sure my MapBox base map styling is public, and it is:

    https://api.mapbox.com/styles/v1/mchtcollier/cjhwbg4m613ho2rpn24azrqt9.html?fresh=true&title=true&access_token=pk.eyJ1IjoibWNodGNvbGxpZXIiLCJhIjoiY2pod2JlcnZ3MTg2djNycG14bXQwYmV1OSJ9.u8CFevFbaKc7En25be_OdA#7.9/44.616/-68.874/-30</span></p>
    <p class=”prettyprint prettyprinted”><span class=”pun”>I don’t know what I am missing.</span></p>

    #18290
    jaycollier
    Participant

    I have no idea why styles are showing up in my posts and I can’t edit or delete them. Once again:

    ————————————————————————————

    Yes, thank you. I did see those instructions. However, I am using automatic Leaflet maps generated from custom fields and mashups, and those instructions appeared to apply to the manual editor options: “The new style will appear as a selection in the layers control in the MapPress editor.”

    I am looking for a way to apply the MapBox style automatically to all maps (or via shortcode, which brought me to that outdated help thread.

    By the way, I did add the share URL to the MapBox Settings (“Styled Maps”) screen, giving it a name of “preserves1″ and used it in my mashup shortcode, but that didn’t change the styling either.

    The following shortcode is in brackets: mashup query=”preserve_region=southern maine” style=”preserves1″

    I also checked to make sure my MapBox base map styling is public, and it is:

    https://api.mapbox.com/styles/v1/mchtcollier/cjhwbg4m613ho2rpn24azrqt9.html?fresh=true&title=true&access_token=pk.eyJ1IjoibWNodGNvbGxpZXIiLCJhIjoiY2pod2JlcnZ3MTg2djNycG14bXQwYmV1OSJ9.u8CFevFbaKc7En25be_OdA#7.9/44.616/-68.874/-30

    I don’t know what I am missing.

    #18291
    Chris
    Keymaster

    I think I see the problem – there is no ‘style’ attribute for shortcodes.  Once you set up your custom style in the MapPress settings, you use it in a shortcode with the ‘maptypeid’ attribute:

    [mashup maptypeid="preserves1" query="all"]
    #18292
    jaycollier
    Participant

    Bingo, that was exactly what I needed for the shortcode! Thank you.

    Is there any way to apply that maptypeid to the automatically-generated maps?

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.