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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:14:52+00:00 2026-05-29T05:14:52+00:00

I’m trying to open the info window when a user clicks on a link

  • 0

I’m trying to open the info window when a user clicks on a link from outside the map. Not sure what I’m missing here. Basically, I have a list of cities with an id for each (var ids loops over the ids). When the user clicks on that link (on click=”myclick(‘1’)” id like the infowindow for that city(1 = london etc) to open up.

Any help would be appreciated.

var url = "my json link";
var gmarkers = [];

function initialize() {

var myLatlng = new google.maps.LatLng(0, 0);
var myOptions = {
    zoomControl: true,
    disableDefaultUI: true,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
    };

var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

downloadUrl(url, function(data) {

var j = eval('(' + data.responseText + ')');
var jlength = j.data.cities.length;

var bounds = new google.maps.LatLngBounds();

for(i=0; i < jlength; i++) {

    var x =  parseFloat(j.data.cities[i].lat);
    var y = parseFloat(j.data.cities[i].lon);
    var ids = parseFloat(j.data.cities[i].id);
    var z = new google.maps.LatLng(x,y);
    var title = j.data.cities[i].title;
    var contentstring = 'text'

    var marker = createMarker(ids);

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

    bounds.extend(z);
    map.fitBounds(bounds);

};

if (map.getZoom() == 21) 
    {
        map.setZoom(16);
    }

if (map.getZoom() < 5) 
    {
        map.setZoom(map.getZoom()+1);
    }


    function myclick(i) {
        google.maps.event.trigger(gmarkers[i], 'click');
    };


    function createMarker(){

        var marker = new google.maps.Marker({
            position: z,  
            map: map,
            title: title,
            html: contentstring,
            icon: 'imagelink'
        });

        google.maps.event.addListener(marker,'click',function(){
        infowindow.setContent(this.html);
        infowindow.open(map,marker);
        }); 

            //google.maps.event.addListener(marker,'click',function(){
            //window.location.href = marker.url;
            //});   

        gmarkers[ids] = marker;

    };

});

};

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

function downloadUrl(url, callback) {
  var request = window.ActiveXObject ?
      new ActiveXObject('Microsoft.XMLHTTP') :
      new XMLHttpRequest;

  request.onreadystatechange = function() {
    if (request.readyState == 4) {
      request.onreadystatechange = doNothing;
      callback(request, request.status);
    }
  };

  request.open('GET', url, true);
  request.send(null);
}

function doNothing() {};
  • 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-05-29T05:14:53+00:00Added an answer on May 29, 2026 at 5:14 am

    It looks as if myclick will not be available in global context right now.

    Try to explicitly assign it to the context(window in this case):

    this.myclick=function(i) {
            google.maps.event.trigger(gmarkers[i], 'click');
        };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from

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.