Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Nov 2010
    Location
    London, UK
    Posts
    40
    Thanks
    1
    Thanked 4 Times in 4 Posts

    Google Map API V3 Marker Focus

    Hey Guys,

    I am currently building a web app that uses Google Maps V3 api.

    You select a check box which then shows a marker on the map.

    My issue is, when you select and the marker is placed, I need the map to focus to that point, it currently embeds but doesn't focus.

    Is there a particular function I could use to achieve this?

    My current code is shown below:

    Code:
    var locations = [
        // Longitude, Latitue, Content, Country Code, City Name
    	[51.481383, -3.114967, holidayOverlay, 'UK', 'Cardiff'],
    	[52.362393, 4.893379, holidayOverlay, 'NL', 'Amsterdam'],
    	[48.852314, 2.350089, holidayOverlay, 'FR', 'Paris'],
    	[40.18884, -3.716812, holidayOverlay, 'SP', 'Madrid'],
    	[53.800651, -4.064941, holidayOverlay, 'IT', 'Rome'],
    	[42.041134, 1.889648, holidayOverlay, 'SP', 'Costa Brava'],
    	[36.79334, 27.234421, holidayOverlay, 'GR', 'Kos'],
    	[37.014581, -7.933888, holidayOverlay, 'PT', 'Algarve'],
    	[28.358776, -14.05426, holidayOverlay, 'PT', 'Fuerteventura'],
    	[29.046854, -13.589973, holidayOverlay, 'SP', 'Lanzarote'],
    ];
    
    // Only create marker when checked
    for (i = 0; i < locations.length; i++) {
        if (locations[i][4] == location) {
            var marker = new google.maps.Marker({
                position: new google.maps.LatLng(locations[i][0], locations[i][1]),
                map: map,
                icon: plotImage
            });
            var title = locations[i][4];
            var content = locations[i][2];
        }
    }
    I have left a lot of the code out to save you a headache.

    Thanks.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,155
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    map.setCenter( theCenterGLatLng )
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    digitalclubb (11-12-2010)

  • #3
    New Coder
    Join Date
    Nov 2010
    Location
    London, UK
    Posts
    40
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Amazing.. Thank you


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •