Copied to clipboard

Flag this post as spam?

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


  • Advance Ngwarati 25 posts 127 karma points
    Aug 27, 2019 @ 15:38
    Advance Ngwarati
    0

    Show Marker Label onMouseOver

    Hi Jonathan,

    How can i change onClick Marker to show the label to onMouseOver option? I did not see this in the manual.

    Thanks in advance.

    Regards,

    Advance.

  • Jonathan Richards 288 posts 1742 karma points MVP
    Aug 27, 2019 @ 19:52
    Jonathan Richards
    0

    Hi Advance,

    There isn't some setting in Terratype that allows this to be done easily.

    You can do it yourself by hooking into the onRender event

    <script>
        terratype.onRender(function (provider, map) {
            if (provider.id == 'Terratype.GoogleMapsV3') {
                for (var p = 0; p != map.positions.length; p++) {
                    var marker = map.positions[p].handle;
                    var info = map.positions[p]._info; // This is a hack
    
                    marker.addListener('mouseover', function() {
                        infowindow.open(map, info);
                    });
                }
            }
        });
    </script>
    

    Need to add this script block to the bottom of your page, after the @Html.Terratype()

    Disclaimer: I haven't tested this code and you will have to look at the Google Maps V3 api to sort out any issues, but hopefully it will send you in the right direction.

    Cheers

    Jonathan Richards

  • Advance Ngwarati 25 posts 127 karma points
    Aug 28, 2019 @ 07:42
    Advance Ngwarati
    0

    Thanks Jonathan,

    I implement the solution you provided, but i just have a question, is infowindow.open() is already defined globally in package? When i'm trying to run the code it is showing "ReferenceError: infowindow is not defined" and i tried to defined it locally following the Google Maps V3 but i'm getting this error "TypeError: map.infoWindow is not a function". This is how i'm defining it, check the code below:

    terratype.onRender(function (provider, map) {
        console.log(provider);
        console.log(provider);
        if (provider.id == 'Terratype.GoogleMapsV3') {
            for (var p = 0; p != map.positions.length; p++) {
                var marker = map.positions[p].handle;
                var info = map.positions[p]._info; // This is a hack
                var infoWindow = map.infoWindow();
    
                marker.addListener('mouseover', function() {
                    infoWindow.open(map, info);
                });
            }
        }
    });
    

    Regards,

    Advance

  • Jonathan Richards 288 posts 1742 karma points MVP
    Aug 28, 2019 @ 08:12
    Jonathan Richards
    0

    Hi Advance,

    Try this

    terratype.onRender(function (provider, map) {
        console.log(provider);
        console.log(provider);
        if (provider.id == 'Terratype.GoogleMapsV3') {
            for (var p = 0; p != map.positions.length; p++) {
                var marker = map.positions[p].handle;
                var info = map.positions[p]._info; // This is a hack
    
                marker.addListener('mouseover', function() {
                    info.open(map, info);
                });
    
                marker.addListener('mouseout', function() {
                    info.close();
                });         
            }
        }
    });
    

    Cheers

    Jonathan Richards

  • Advance Ngwarati 25 posts 127 karma points
    Aug 28, 2019 @ 08:23
    Advance Ngwarati
    0

    Thanks again Jonathan,

    Now i'm getting "too much recursion " on Firefox, then on Chrome "Uncaught RangeError: Maximum call stack size exceeded" enter image description here

    Regards,

    Advance

Please Sign in or register to post replies

Write your reply to:

Draft