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 8755911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:56:54+00:00 2026-06-13T13:56:54+00:00

I have started playing around with Geolocation, and I can get the co-ordinates etc.

  • 0

I have started playing around with Geolocation, and I can get the co-ordinates etc. I want to show this in a map, but when I return the map to the div nothing gets displayed. Now I looked in the div, and the map is being returned but just not visibile. This is the div in question

Notice this seems to be just a link to a tiny map

  <a style="position: static; overflow-x: visible; overflow-y: visible; float: none;                 display:     inline; " target="_blank" href="http://maps.google.com/maps?ll=51.263519,-7.124185&amp;z=21&amp;t=m&amp;hl=en-US" title="Click to see this area on Google Maps"><div style="width: 62px; height: 24px; cursor: pointer; "><img style="position: absolute; left: 0px; top: 0px; -webkit-user-select: none; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; width: 62px; height: 24px; " src="http://maps.gstatic.com/mapfiles/google_white.png" draggable="false"></div></a>

This is what I’m doing,Html

Home

Your location

<div data-role="content" id="location1">
<div  id="map" style="width:100%; height:100%"></div>

My model is as follows

      bb.model.Map = Backbone.Model.extend({
  defaults: {
    center: new google.maps.LatLng(51.26351898,-6.14462727),
    zoom: 20,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }
});

My view is as follows

     bb.view.Location = Backbone.View.extend(_.extend({  

   id: 'map',
   initialize: function(){
     this.map = new google.maps.Map(this.el, this.model.attributes);
 this.render();
   },
 render: function(){
 //    $('#map').replaceWith(this.el);
   $('#map').replaceWith(this.el);
      $('#location-page').page();

   },

}))

I’m also using the following script.

      <script type="text/javascript"  src="http://maps.google.com/maps/api/js?sensor=false"></script>   
  • 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-13T13:56:55+00:00Added an answer on June 13, 2026 at 1:56 pm

    You have various problems here so we’ll go top to bottom.

    When you say this:

    <div data-role="content" id="location1">
        <div  id="map" style="width:100%; height:100%"></div>
    </div>
    

    The 100% width and height values on #map refer to the parent element so you’re saying

    make #map the same size as #location1

    By default, a <div>, like all block elements, will be as wide as its parent (assuming that there’s no margins, padding, … in the way) and be tall enough to contain its content. If you don’t have any CSS that forces #location1 to be a specific size then it will be as wide as the page (or whatever parent it has) and it will have a height of zero. That means that #map will also be zero pixels tall. So you’ll need to make sure #location1 has an assigned height.

    When you say this in a view definition:

    id: 'map',
    

    you’re only telling Backbone to set id="map" on the <div> it creates for your view:

    el view.el

    […] this.el is created from the view’s tagName, className, id and attributes properties, if specified. If not, el is an empty div.

    Saying id: 'map' doesn’t grab #map from the DOM to use as the view’s el, it just leaves you with <div id="map"></div> as your view’s el. You probably want to specify el in the view definition:

    el: '#map'
    

    You seem to be trying to correct the view’s el confusion using replaceWith. That should work, more or less, but you’d still be binding the map to a zero height <div> and then putting that zero height <div> into the DOM. Short is fine but you can’t see something that is 0px tall.

    Also, you don’t need Backbone.View.extend(_.extend({ ... }));, you only need Backbone.View.extend({ ... });.

    Assuming that you have something to give #location1 a height, then a view like this:

    Backbone.View.extend({
        el: '#map',
        initialize: function() {
            this.map = new google.maps.Map(
                this.el,
                this.model.toJSON()
            );
            this.render();
        },
        render: function() {
            return this; // This is standard practice.
        }
    });
    

    should get things moving.

    Demo: http://jsfiddle.net/ambiguous/ue4zL/1/

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

Sidebar

Related Questions

I have started playing around with Berkeley DB. This one is really interesting, but
I have been playing around with this and wanted to get a second opinion.
I have started playing around with db4o but quite soon I have run into
I just started playing around with JSON and I have created this example. var
I have just started playing around with Log4Net... I now want to send an
I have started playing around with Apache camel recently. So being the experimental type
I've started playing around with transitions and have come up against quite a big
i have just started playing aorund with asp.net mvc and i want to view
I have started playing with UIProgressView in iOS5, but havent really had luck with
I have started implementing Subscriptions into my app but I cannot get the API

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.