Question

USE an API You have a drop down list of 4 cities. Upon selecting a particular...

USE an API

You have a drop down list of 4 cities. Upon selecting a particular city, longitude, latitude and marker of the location is shown on Google Maps.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is a small example of using Google Maps API for the same:

we are storing the coordinates by the city key. When the selection is made in the dropdown list, we are taking the value, fetching the coordinates and calling the method setCenter.

var map;
function myMap() {
  var mapCanvas = document.getElementById("map");
  var mapOptions = {  
    center: new google.maps.LatLng(40.685646, -76.195499), 
    zoom: 10 
  };
  map = new google.maps.Map(mapCanvas, mapOptions);
}

myMap();

var cord = {
  'NDL': '28.644800, 77.216721',
  'NYC': '40.875597,-77.776226',
  'PAR': '48.864716, 2.349014'
};

function changeMap(city) {
  var c = cord[city].split(',');
  map.setCenter(new google.maps.LatLng(c[0], c[1]));
}
<script src="https://maps.googleapis.com/maps/api/js"></script>

<div>
  <h2>Please Choose a City</h2>
</div>
<form>
  <fieldset>
    <label>
      Cities
    </label>
    <select id="myCity" name="myCity" onchange="changeMap(this.value)">
      <option value="None">Select a City</option>
      <option value="NDL">New Delhi, IN</option>
      <option value="NYC">New York, PA</option>
      <option value="PAR">Paris, FR</option>
    </select>
  </fieldset>
</form>
<div id="map"></div>
#map {
  height: 200px;
}
Add a comment
Know the answer?
Add Answer to:
USE an API You have a drop down list of 4 cities. Upon selecting a particular...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (The cities.txt file is just a list of almost 30,000 cities and their distance from Charlotte)...

    (The cities.txt file is just a list of almost 30,000 cities and their distance from Charlotte) Your goal is to print the cities in United States sorted in the increasing order of distance from Charlotte. Download from Canvas the text file (cities.txt containing the latitude and longitude information of nearly 30,000 cities in the United States. Calculate the distance from Charlotte to each of these cities. Sort the cities in ascending order of distance, and print the sorted list along...

  • Java Concurrency! You have been given a simple API to buy and print postage. Write a...

    Java Concurrency! You have been given a simple API to buy and print postage. Write a program that submits each incoming order to the API and then prints the shipping label. Unfortunately each call to the shipping label API is SLOW… To compensate for this, use concurrency so that your program can be making several calls to the API at one time. We also need to keep track of our expenses, so make sure to calculate how much money is...

  • Could someone let me know the correct answers for these questions?

    Question 1A finite-state machine (FSM) can serve as a useful model of a continuous (all its variables / attributes have real number values with infinite range and precision) environment. Yes or no?YesNo       Question 2Breadth-first and depth-first tree searches always start the search process at the root of the tree. Yes or no?YesNo      Question 3Consider a single-agent system where some agent A can travel to every place on the surface of the Earth (environment). Every place (environment state) on Earth can...

  • You have worked the Carolina Mobile Home transportation problem. Suppose there is a down turn in ...

    Can you please help me solve this problem? Thank you! You have worked the Carolina Mobile Home transportation problem. Suppose there is a down turn in business and the sales lots must reduce sales by one mobile home per month to all locations except Charlotte. That is, Richmond will need 7 Greensboro will need 3 and Columbia will need 8 per month. What is the new Z value (shipping cost per month)? Is this a max or min problem? min...

  • 2. Here is a sorting algorithm that I like to use. Given an unsorted list of...

    2. Here is a sorting algorithm that I like to use. Given an unsorted list of size n, let Xx represent the data in location k of the unsorted list. Compare xi to X2 and switch if necessary so that they are in sorted order, smallest first. Compare Xn-1 and Xn and switch if necessary so that they are in sorted order, smallest first. • Compare x3 with its left neighbors, switching if necessary so that the 3 first entries...

  • 4. For a particular disease, the chance of a patient getting cured is 60%. You have...

    4. For a particular disease, the chance of a patient getting cured is 60%. You have randomly selected 150 patients and you are interested to calculate the probability that exactly 100 patients get cured. What mean and standard deviation will you use for the normal approximation of this binomial problem? 4a-What would be the probability that exactly 100 patients got cured in problem 4 above?

  • 1-. List three "big questions" you have about the solid Earth or Earth Process. An example...

    1-. List three "big questions" you have about the solid Earth or Earth Process. An example would be "Have the Himalaya mountains always been this tall and why" or "Why do we have so many Earthquakes every day".  Note: This is a physical geology course, keep your questions relevant.  In other words, the physical world and natural processes we live in. NO Biology questions about bacteria, Yetis, llamas, frogs, etc. 2-. What are some ways that you could start to find the answers, and HOW exactly would...

  • QUESTION 25 4 points One way to quantify the advantage you have in a particular business...

    QUESTION 25 4 points One way to quantify the advantage you have in a particular business over competition is to use which of the following. O perceptual mapping. O regression analysis O multiattribute model correlation analysis

  • Survey the prices of a particular product or service in three different locations near you. Explain why the price of the same product or service varies based upon what you have learned from this cours...

    Survey the prices of a particular product or service in three different locations near you. Explain why the price of the same product or service varies based upon what you have learned from this course. Follow the following steps to complete this assignment. 1. Describe the product or service of your choice. Clearly indicate when and where you survey and record the prices. 2. Use professional economic terms or theory to explain why the prices are different through your research....

  • Write a simple todo list application. This will require use of classes, objects, and possibly structs....

    Write a simple todo list application. This will require use of classes, objects, and possibly structs. Here are the requirements: 1. Menu-driven - upon running the program, the user should be prompted to press one of the following: 1. View all Todos in list 2. Remove a todo item from the list * if there are not any todos, the user should be prompted and sent back to the menu * choose a todo from list based on title to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT