Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Allan Hawkey 232 posts 303 karma points
    Mar 07, 2011 @ 12:23
    Allan Hawkey
    0

    Macro error

    I have a macro set up to display a Google Map, and I use the macro to allow users to enter up to 25 markers for the map, plus a label and info field for each.  This has been working fine, as most instances of the map just contain a few markers.

    However, I now have the situation where a user needs to use all 25 markers - they enter the details correctly and save and publish the page and all is well.

    But when they go back to edit the content of the page (editing the macro in the Rich Text editor) they get a 404 error.

    It seems that this may be caused by the "insert macro" button being limited to a maximum amount of characters in the macro paarmeters.

    Does anyone know if this is correct and, if so, how to extend the number of characters allowed?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 07, 2011 @ 17:33
    Jan Skovgaard
    0

    Hi Allan

    What version of Umbraco are you using?

    I'm not aware that there should be a limit on how many parameters you add to a macro - but perhaps there is a bug with it on the version you're using?

    A bit off topic...is there any specific reason why you set the markers as parameters directly on the macro instead of using a document type to represent a marker,s o it can be grouped in a folder in a repository in the content section perhaps? That way it will be easier to maintain and there are no limits on how many markers could be added...Don't know if you have thought about it or if it makes sense in your context...but I can just imagine how cumbersome it is to change parameters on the macro if the customer all of the sudden want to have another sort order on them..:-)

    /Jan

  • Allan Hawkey 232 posts 303 karma points
    Mar 07, 2011 @ 17:51
    Allan Hawkey
    0

    Hi Jan

    Thanks for your reply.

    To answer your first question, it's v 4.5.2.

    Re the second question, there's no specific reason other than, as a relative novice on Umbraco, that was the only way I could see to do it!  Any further guidance on the steps to do this would be gratefully received as you are right, it is cumbersome!

    I can set up document types ok, but would then need to call them somehow into my Map macro?

    Thanks
    Allan

  • Allan Hawkey 232 posts 303 karma points
    Mar 07, 2011 @ 18:46
    Allan Hawkey
    0

    OK - so I created a document type for the Map Markers, with 3 properties:  marker, label and info.

    I have also created a macro with 4 parameters - centre, mapwidth, mapheight, zoom.

    Now I need to create the xslt.

    Here's what I have so far, though it has errors and doesn't work!  I need this to cycle through and pick up the marker details for all markers set up (if any), and display them on the map.  I guess I need to set up the variables etc somehow for each marker and label them 1, 2 etc.

    Not really sure how to do this, so any help gratefully received:

    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>
    <xsl:variable name="centre" select="/macro/centre"/>
    <xsl:param name="zoom" select="/macro/zoom"/>
    <xsl:param name="mapwidth" select="/macro/mapwidth"/>
    <xsl:param name="mapheight" select="/macro/mapheight"/>

    <xsl:template match="/">

    <!-- start writing XSLT -->

    <div id="map_canvas" style="width:{$mapwidth}px; height:{$mapheight}px; margin:10px;">&nbsp;</div>

    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&amp;region=GB">&nbsp;</script>
    <script type="text/javascript">
      function initialize() {
        var latlng = new google.maps.LatLng(<xsl:value-of select="$centre"/>);
        var myOptions = {
          zoom: <xsl:value-of select="$zoom"/>,
          center: latlng,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        var map = new google.maps.Map(document.getElementById("map_canvas"),
            myOptions);


            <xsl:if test="count($currentPage/MapMarker)&gt;0">
                <xsl:for-each select="$currentPage/MapMarker">
    var myLatlng1 = new google.maps.LatLng(<xsl:value-of select="$marker"/>);

    var contentString1 = '<div id="content1">'+
        '<div id="siteNotice1">'+
        '<xsl:value-of select="$Info"/>'+
        '</div>'+
        '</div>';

        var infowindow1 = new google.maps.InfoWindow({
          content: contentString1,
          maxWidth: 200
      });    
        
        var marker1 = new google.maps.Marker({
          position: myLatlng1,
          map: map,
          title:"<xsl:value-of select="$Label"/>"
      });   

    google.maps.event.addListener(marker1, 'click', function() {
      infowindow1.open(map,marker1);
    });
                </xsl:for-each>
            </xsl:if>
    </script>
    <img src="/umbraco/images/nada.gif" onload="javascript:initialize();" />
    </xsl:template>

    </xsl:stylesheet>

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 07, 2011 @ 22:33
    Jan Skovgaard
    0

    Hi Allan

    What kind of errors do you receive? I suppose that you need each marker to have a unique name, right?

    In the case you could use position() to make sure each marker has a unique name...like this

    var marker<xsl:value-of select="position()" />

    and then you can reference it with marker<xsl:value-of select="position()" /> where needed I guess.

    Does this work?

    /Jan

  • Allan Hawkey 232 posts 303 karma points
    Mar 08, 2011 @ 11:01
    Allan Hawkey
    0

    Hi Jan

    Thanks for your suggestions here.

    Here's the error I'm getting with the code I posted previously - maybe I'm calling the value of the marker incorrectly from the MapMarker document?

    Error occuredError in XSLT at line 40, char 40
    38:       <xsl:if test="count($currentPage/MapMarker)&gt;0">
    39:       <xsl:for-each select="$currentPage/MapMarker">
    40: >>>  var myLatlng1 = new google.maps.LatLng(<xsl:value-of select="$marker"/>); <<<
    41:      
    42:      var contentString1 = '<div id="content1">'+

    Re your suggestion of using position(), how will this work inside " " ?

    E.g. in the code below, I think the second part of the line is probably wrong?

    var contentString<xsl:value-of select="position()" /> = '<div id="content<xsl:value-of select="position()" />">'

    Thanks
    Allan

    
    
                
  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 08, 2011 @ 12:28
    Jan Skovgaard
    0

    Hi Allan

    It's probably because of the mix with XSLT and JavaScript - please post the whole XSLT code from the file in here, so it's easier to get an overview and guide you on how to do this - you need to make som non-pretty workarounds when using XSLT and JavaScript in a combination like this.

    /Jan

  • Allan Hawkey 232 posts 303 karma points
    Mar 08, 2011 @ 14:39
    Allan Hawkey
    0

    Hi Jan

    I posted the whole of the XSLT yesterday (except the standard top few lines) - does that answer your question, or are you looking for something else?

    Thanks again
    Allan

  • Allan Hawkey 232 posts 303 karma points
    Mar 14, 2011 @ 12:34
    Allan Hawkey
    0

    Hi Jan

    Just wondered if you'd had a chance to take a look at this?  I'm still looking to get this resolved...

    Many thanks

    Allan

Please Sign in or register to post replies

Write your reply to:

Draft