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

  • SEARCH
  • Home
  • 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 9267711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:37:01+00:00 2026-06-18T14:37:01+00:00

I have this map: …. class Maps …. Maps.prototype.initialize = function (x, y) {

  • 0

I have this map:

.... class Maps .... 

Maps.prototype.initialize = function (x, y) {
    var latitude = x;
    var longitude = y;

    var mapOptions = {
        zoom: 8,
        center: new google.maps.LatLng(latitude, longitude),
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };

    var map = new google.maps.Map(document.getElementById('map_canvas'),  mapOptions);

    var marker = new google.maps.Marker({
        position: map.getCenter(),
        map: map,
        title: 'Click to zoom'
    });
};

Maps.prototype.changePosition = function (x, y) {

    var latitude = x;
    var longitude = y;

    var map = new google.maps.LatLng(latitude, longitude);
    marker.setPosition(map);
}

....

then:

var maps = new Maps();
var marker = maps.initialize(x, y);

window.setTimeout(function() {
    maps.changePosition(x, y));
}, 3000);

the initialize method works, and renders the map and the marker

but the second one doesn’t work, doesn’t know what setPosition is

any ideas on this issue?

  • 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-18T14:37:03+00:00Added an answer on June 18, 2026 at 2:37 pm

    There are different issues.

    the first one, which will prevent the code from executing: your iinitialize-function doesn’t have a return-value, so your maps-variable is undefined and didn’t have a method changePosition.

    Later: the changePosition has to arguments , z and y , but inside the function you access the variables x and y

    However, I don’t see any code that modifies x and y , so even when the code would work it doesn’t have any visible effect.


    function Maps(){}
    
    Maps.prototype.initialize = function (x, y, z, o) {
    
        this.center    = new google.maps.LatLng(x, y)
        this.zoom      = z;
        this.node      = document.getElementById(o);
        this.markers   = [];
    
        var mapOptions = {
            zoom:       this.zoom,
            center:     this.center,
            mapTypeId:  google.maps.MapTypeId.ROADMAP
        };
    
        this.map = new google.maps.Map(this.node,  mapOptions);
    
        return this;
    };
    
    Maps.prototype.addMarker=function(x, y, t , c){
    
      var marker = new google.maps.Marker({
            position: new google.maps.LatLng(x,y),
            map: this.map,
            title: t||'Click to zoom'
        });
    
      this.markers.push(marker);
      if(c)this.map.setCenter(marker.getPosition());
      return marker;
    }
    
    Maps.prototype.changePosition = function (m , x, y, c, f) {
    
        var latLng = new google.maps.LatLng(x, y);
        m.setPosition(latLng);
        if(c)this.map.setCenter(latLng);
        if(f)f();
    }
    
    //create the Maps-instance
    var maps = new Maps(),
        x = 10,
        y = 10;
    
    //do something onload
    google.maps.event.addDomListener(window,'load',function(){
      //initialize maps
      maps.initialize(x, y , 3, 'map_canvas');
    
      //add a marker
      var marker=maps.addMarker(x, y ,'hello marker', true);
    
      //change position of marker
      window.setTimeout(function() {
        maps.changePosition(marker, x+50, y+50 ,true,
                            function(){alert('position changed');});
    }, 5000);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this function var map = [ &\#1632;,&\#1633;,&\#1634;,&\#1635;,&\#1636;, &\#1637;,&\#1638;,&\#1639;,&\#1640;,&\#1641; ]; function getArabicNumbers(str) {
I have this class which i would like to map: public class Contract {
I have this code: var nodeMap:Map[Int, List[Node]] = Map[Int, List[Node]]() nodeMap = Map[Int, List[Node]]()
in my function, i have this parameter: map<string,int> *&itemList I want to first check
I have something like this <c:set var=x value=a /> Supposing I have a map
In my routes.rb I have this: map.namespace :admin do |admin| admin.resources :galleries do |galleries|
I have a problem that I can't resolve. Let's say I have this map
I have something like this: Map<String, String> myMap = ...; for(String key : myMap.keySet())
I have this code in Android: Map<String, String> idObject1 = new LinkedHashMap<String, String>(); idObject1.put(Id,
I have this as a return type in Scala Map[String, Seq[Map[String, Seq[MyClass]]]] I have

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.