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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:29:50+00:00 2026-06-14T23:29:50+00:00

I have a liitle problem when i try to change location. I`m connected to

  • 0

I have a liitle problem when i try to change location. I`m connected to map

var mapOptions = {
   zoom: 7,
   center: new google.maps.LatLng(48.379433, 31.165579999999977),
   mapTypeControl: false,
   mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);

And now I need to change location on the map

<select onChange="changeCity()" id="city"><option value="50.4501, 30.523400000000038">Київ</option><option value="49.839683, 24.029717000000005">Львів</option></select>

For that I`m using:

function changeCity() {
   var city = document.getElementById('city').value;
   var city_1 = new google.maps.LatLng(city);
   map.setCenter(city_1);
}

But nothing happens (i see grey area). Please help…!

  • 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-14T23:29:52+00:00Added an answer on June 14, 2026 at 11:29 pm

    The problem is that

    somefunction("xx.xxxxxxx, xx.xxxxxxx");
    

    is not equivalent to

    somefunction(xx.xxxxxxx, xx.xxxxxxx);
    

    Your values in the option tags are specified as single string instances, like "50.4501, 30.523400000000038" for Kiev. Notice the double quotes.

    The new LatLng() constructor would expect two numeric values. So you have to parse the value string into separate latitude and longitude values and pass them to the new LatLng() constructor:

    function changeCity() {
    
        var cityString = document.getElementById('city').value;
        //value string is split into two parts by the ',' character
        var arrayOfValues = cityString.split(','); 
        //parse latitude string part to a floating point value (first part)
        var lat = parseFloat(arrayOfValues[0]);
        //parse longitude string part to a floating point value (second part)
        var lon = parseFloat(arrayOfValues[1]);
        //create new LatLng instance with correct values
        var city_1 = new google.maps.LatLng(lat, lon);
        map.setCenter(city_1);
    }
    

    Reference:

    • Google Maps API docs: LatLng
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little problem about Google Maps. I'm using Geocoding (xml) for getting
I have created a little test project to try to resolve a problem I
I have a little problem. This is my code: stackPanelShapesContainer = new StackPanel(); InitializeStackPanle();
I have a little problem with my script. When I try to run it
I have a problem with glViewport. In my liitle programm i have two viewports.
I try to validate my xhtml and i have a little problem with this:
i have a litle problem here, i try to create some AI that will
I'm new here on stackoverflow. I have a little problem with my Android app,
I have a little problem. I have created an android api that uses google
I have little problem with a replacement of a little part in an url.

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.