Copied to clipboard

Flag this post as spam?

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


  • wayne nixon 12 posts 32 karma points
    Jan 31, 2014 @ 23:36
    wayne nixon
    0

    Google Map of locations not showing just blank space

    My Umbraco map was showing up fine then just created a blank space. site is using umbraco and code shows up in firebug any ideas please.

    http://www.teeslaw.co.uk/map-of-locations/

    heres the backend code cshtml script file:

    @using umbraco.MacroEngines
    @inherits umbraco.MacroEngines.DynamicNodeContext
    @{
    const string widgetName = "widget_all_office_locations_map";
    var officeLocations = Model.Descendants("OfficeLocation");
    if(!officeLocations.Any()){
    officeLocations = new DynamicNode(-1).DescendantsOrSelf("OfficeLocation");
    }
    if (PageData["HasMapWidget"] != null){
    <p>Map is already rendered on @PageData["MapWidget"]</p>
    return;
    }
    PageData.Add("HasMapWidget", true);
    PageData.Add("MapWidget", widgetName);
    }
    <div class="section">
    <div class="section-heading">
    <h3>@Parameter.Title</h3>
    </div>
    <p class="summary">@Parameter.Summary</p>
    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"> </script>
    <script type="text/javascript">
    var geocoder;
    var map;

    function initialize_map() {
    geocoder = new google.maps.Geocoder();
    var latlng = new google.maps.LatLng(52.879076,-1.873169);
    var mapOptions = {
    zoom: 7,
    center: latlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    disableDefaultUI: true
    }
    map = new google.maps.Map(document.getElementById('map_canvas_large'), mapOptions);
    var addrs = [];
    var mrks = [];
    @foreach (var office in officeLocations){
    var address = office.Address.Replace("\r\n","").Replace("\n","");
    var addressHtml = @library.ReplaceLineBreaks(office.Address).Replace("\n", "");
    <text>mrks.push('<div style="width:300px"><h4>Tees Solicitors @office.Name</h4><address>'+escape("@Html.Raw(addressHtml)")+'</address><p><strong>T</strong>: @office.TelephoneNumber</p></div>');</text>
    <text>addrs.push('@address')</text>
    }
    for(var i=0;i<addrs.length;i++) {
    codeAddress(addrs[i], mrks[i]);
    }

    }

    var iws = [];
    function codeAddress(address, contentString) {
    geocoder.geocode({ 'address': address }, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
    //map.setCenter(results[0].geometry.location);
    var marker = new google.maps.Marker({
    map: map,
    position: results[0].geometry.location
    });

    var infowindow = new google.maps.InfoWindow({
    content: unescape(contentString)
    });

    google.maps.event.addListener(marker, 'click', function() {
    for(var i=0;i<iws.length;i++) {
    iws[i].close();
    }
    infowindow.open(map, marker);
    });

    iws.push(infowindow);
    }
    });
    }

    $(function () {
    initialize_map();
    });
    </script>
    <div id="map_canvas_large" class="span6" style="margin-left:0;height: 724px"></div>
    </div>

     

Please Sign in or register to post replies

Write your reply to:

Draft