Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8217527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:29:35+00:00 2026-06-07T12:29:35+00:00

i am working on an asp.net mvc3 application. I am trying to load a

  • 0

i am working on an asp.net mvc3 application.

I am trying to load a google map inside a partial view but it is not working:

My partial view _Map.cshtml

<style type="text/css">  
    #map_canvas 
    {
        position:absolute;
        top:40px;
        left:12px;
        width:576px;
        height: 450px;
    }

</style>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<div class="sTitle">Name</div>

<div id="map_canvas"></div>


<script type="text/javascript">
var map;
$(document).ready(function () {
    var map;
    var myOptions = {
        zoom: 8,
        center: new google.maps.LatLng(-34.397, 150.644),
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById('map_canvas'),
        myOptions);

    google.maps.event.addDomListener(window, 'load', initialize);
});

</script>

The map is loaded Via an AJAX Call:

         $.ajax({
                type: 'GET',
                url: '@Url.Action("GetMapById", "Map")',
                data: { 'id': sId },
                success: function (html) {
                    $("#content").html(html);
                },
                complete: function () {
                },
                error: function () {
                    alert("There was an error opening the Map. Please try again or contact an administrator");
                }
            });

The partial is loaded in a div named Content

And in the controller I just return the Partial View

 return PartialView("_Map");

The View is loading but the map is not visible.

I used Firebug to track the problem and I got this error:

“google is not defined”

Any idea about the problem?

Thanks a lot

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T12:29:36+00:00Added an answer on June 7, 2026 at 12:29 pm

    I solved this by putting this

    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
    

    in the Layout page nad not in the subview

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on an application that uses asp.NET mvc3. I created a partial view,
I'm working on an ASP.NET website (MVC3 but not really important for my question)
I am working on an ASP.NET MVC3 application. In the Views I created a
I'm working on ASP.net MVC3 Web application that is facing scalability issue. For improving
I'm working on Asp.net MVC3 web application. I'm having one page on which appx.
I'm working on a ASP.NET MVC3 web application and I want to create a
I am working on ASP.NET 4.0 MVC3 web application that works in intranet environment.
I am working on a web application (asp.net mvc3) I have a Main div.
I'm working with ASP.NET MVC3, and I'm trying to get absolute control over my
I am working on asp.net MVC 3 application. I have created a Razor view

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.