如何在Google Maps API

时间:2015-11-27 20:53:13

标签: google-maps google-maps-api-3

对于Google Maps API,如何在特定标记上设置中心缩放,而不是bounds的中心?

请参阅下面的小提琴。

想以这个标记为中心:[' 45.Oklahoma City,OK',35.483038,-97.481689]

模板来自://来源:http://wrightshq.com/playground/placing-multiple-markers-on-a-google-map-using-api-3/

代码段(来自链接小提琴):



function initMap() {
  var map;
  var bounds = new google.maps.LatLngBounds();
  var mapOptions = {
    mapTypeId: 'roadmap'
  };

  // Display a map on the page
  map = new google.maps.Map(document.getElementById("map"), mapOptions);
  map.setTilt(45);

  // Display multiple markers on a map
  var infoWindow = new google.maps.InfoWindow(),
    marker, i;

  // Loop through our array of markers & place each one on the map  
  for (i = 0; i < markers.length; i++) {
    var position = new google.maps.LatLng(markers[i][1], markers[i][2]);
    bounds.extend(position);
    marker = new google.maps.Marker({
      position: position,
      map: map,
      title: markers[i][0]
    });

    // Allow each marker to have an info window    
    google.maps.event.addListener(marker, 'click', (function(marker, i) {
      return function() {
        infoWindow.setContent(infoWindowContent[i][0]);
        infoWindow.open(map, marker);
      }
    })(marker, i));

    // Automatically center the map fitting all markers on the screen
    map.fitBounds(bounds);
  }

  // Override our map zoom level once our fitBounds function runs (Make sure it only runs once)
  var boundsListener = google.maps.event.addListener((map), 'bounds_changed', function(event) {
    this.setZoom(4);
    google.maps.event.removeListener(boundsListener);
  });

}

// Multiple Markers
var markers = [
  ['1. New York, New York', 40.747257, -73.953094],
  ['2. Los Angeles', 34.040143, -118.243103],
  ['3. Chicago, IL', 41.869561, -87.622833],
  ['4. Philadelphia, PA', 39.943436, -75.164337],
  ['5. Dallas / Fort Worth', 32.7688, -96.855469],
  ['6. San Francisco-Oakland-San Jose', 37.773429, -122.418938],
  ['7. Boston, MA & Manchester , NH', 42.352455, -71.058197],
  ['8. Atlanta, GA', 33.754031, -84.388733],
  ['9. Washington, DC / Hagerstown, MD', 38.892636, -77.023087],
  ['10. Houston, TX', 29.756032, -95.362701],
  ['11. Detroit, MI', 42.324032, -83.044968],
  ['12. Phoenix, AZ', 33.417687, -112.07428],
  ['13. Tampa / Sarasota, FL', 27.974998, -82.450333],
  ['14. Seattle / Tacoma, WA', 47.614958, -122.347183],
  ['15. Minneapolis / St Paul, MN', 44.971599, -93.264313],
  ['16. Miami / Fort Lauderdale, FL', 25.770832, -80.190239],
  ['17. Cleveland / Akron, OH', 41.493664, -81.692963],
  ['18. Denver, CO', 39.751017, -104.988098],
  ['19. Orlando / Daytona Beach / Melbourne, FL', 28.537481, -81.366119],
  ['20. Sacramento/Stockton/Modesto, CA', 38.568569, -121.486816],
  ['21. St. Louis, MO', 38.622235, -90.197754],
  ['22. Portland, OR', 45.525592, -122.678833],
  ['23. Pittsburgh, PA', 40.438586, -80.013428],
  ['24. Charlotte, NC', 35.209722, -80.90332],
  ['25. Indianapolis, IN', 39.774769, -86.176758],
  ['26. Baltimore, MD', 39.283294, -76.629639],
  ['27. Raleigh-Durham (Fayetteville), NC', 35.038992, -78.892822],
  ['28.San Diego, CA', 32.694866, -117.180176],
  ['30.Hartford & New Haven, CT', 41.537366, -72.743225],
  ['31.Kansas City, MO', 39.085304, -94.584045],
  ['32.Columbus, OH', 39.962386, -83.000336],
  ['33.Salt Lake City, UT', 40.768582, -111.887512],
  ['34.Cincinnati, OH', 39.094897, -84.518509],
  ['35.Milwaukee, WI', 43.038783, -87.912598],
  ['38.West Palm Beach-Ft. Pierce, FL', 26.725987, -80.117798],
  ['39.Grand Rapids-Kalamazoo-Battle Creek, MI', 42.912183, -85.671387],
  ['40.Birmingham (Anniston and Tuscaloosa), AL', 33.507049, -86.812592],
  ['36.Greenville-Spartanburg, SC-Asheville, NC-Anderson,SC', 34.813803, -82.419434],
  ['41.Harrisburg-Lancaster-Lebanon-York, PA', 40.191463, -76.830139],
  ['42.Las Vegas, NV', 36.151182, -115.169678],
  ['43.Norfolk-Portsmouth-Newport News, VA', 36.840065, -76.330261],
  ['44.Albuquerque-Santa Fe, NM', 35.424868, -106.292725],
  ['45.Oklahoma City, OK', 35.483038, -97.481689],
  ['47.Jacksonville, FL', 30.315988, -81.657257],
  ['48.Memphis, TN', 35.136756, -90.049438],
  ['49.Austin, TX', 30.264998, -97.742615],
  ['50.Louisville, KY', 38.254358, -85.749664],
  ['51.Buffalo, NY', 42.885776, -78.877029],
  ['52.Providence, RI-New Bedford, MA', 41.647775, -70.96344],
  ['53.New Orleans, LA', 29.916852, -90.087891],
  ['54.Wilkes Barre-Scranton, PA', 41.248644, -75.864716],
  ['55.Fresno-Visalia, CA', 36.558188, -119.602661],
  ['56.Little Rock-Pine Bluff, AR', 34.730327, -92.28653],
  ['57.Albany-Schenectady-Troy, NY', 42.74197, -73.817139],
  ['58.Richmond-Petersburg, VA', 37.205722, -77.389755],
  ['59.Knoxville, TN', 35.96189, -83.923874],
  ['60.Mobile, AL-Pensacola (Ft. Walton Beach), FL', 30.465247, -87.203979],
  ['61.Tulsa, OK', 36.132329, -95.971069],
  ['62.Ft. Myers-Naples, Fl', 26.346345, -81.824799],
  ['63.Lexington, KY', 38.048226, -84.499969],
  ['64.Dayton, OH', 39.762631, -84.205399],
  ['65.Charleston-Huntington, WV', 38.408406, -82.062378],
  ['66.Flint-Saginaw-Bay City, MI', 43.276205, -83.84079],
  ['67.Roanoke-Lynchburg, VA', 37.32212, -79.656372],
  ['68.Tucson (Sierra Vista), AZ', 32.222096, -110.939941],
  ['69.Wichita-Hutchinson, KS Plus', 37.870517, -97.662964],
  ['70.Green Bay-Appleton, WI', 44.364115, -88.177643],
  ['71.Des Moines-Ames, IA', 41.73033, -93.383789],
  ['72.Honolulu, HI', 21.294493, -157.82135],
  ['73.Toledo, OH', 41.65188, -83.577461],
  ['74.Springfield, MO', 37.195878, -93.284912],
  ['75.Spokane, WA', 47.65105, -117.409514999999],
  ['76.Omaha, NE', 41.258194, -95.942917],
  ['77.Portland-Auburn, ME', 43.91768, -70.032349],
  ['78.Paducah, KY-Cape Girardeau, MO-Harrisburg, IL', 37.049697, -88.608856],
  ['79.Columbia, SC', 33.994612, -81.033783],
  ['80.Rochester, NY', 43.151098, -77.617035],
  ['81.Syracuse, NY', 43.049823, -76.146584],
  ['82.Huntsville-Decatur (Florence), AL', 34.661452, -86.779633],
  ['83.Champaign & Springfield-Decatur, IL', 39.901309, -88.901367],
  ['84.Shreveport, LA', 32.512078, -93.747025],
  ['85.Madison, WI', 43.059356, -89.399185],
  ['86.Chattanooga, TN', 35.061477, -85.254593],
  ['87.Harlingen-Weslaco-Brownsville-McAllen, TX', 26.160369, -97.987061],
  ['88.Cedar Rapids-Waterloo-Iowa City & Dubuque, IA', 41.820455, -91.601257],
  ['89.South Bend-Elkhart, IN', 41.689322, -86.10878],
  ['90.Jackson, MS', 32.310349, -90.178528],
  ['91.Colorado Springs-Pueblo, CO', 38.823126, -104.81781],
  ['92.Tri-Cities, TN-VA', 36.487557, -82.353516],
  ['93.Burlington, VT-Plattsburgh, NY', 44.594379, -73.309021],
  ['94.Waco-Temple-Bryan, TX', 31.1564079999999, -96.734619],
  ['95.Baton Rouge, LA', 30.462879, -91.129532],
  ['96.Savannah, GA', 32.076757, -81.095581],
  ['97.Davenport, IA-Rock Island-Moline, IL', 41.482862, -90.502625],
  ['98.El Paso, TX', 31.751525, -106.486359],
  ['99.Charleston, SC', 32.79247, -79.942017],
  ['100.Ft. Smith-Fayetteville-Springdale-Rogers, AR', 36.075742, -94.177551],
  ['101.Johnstown-Altoona, PA', 40.504402, -78.399811],
  ['102.Evansville, IN', 37.975327, -87.541122],
  ['103.Greenville-New Bern-Washington, NC', 35.431582, -77.176208],
  ['104.Myrtle Beach-Florence, SC', 34.020795, -79.373474],
  ['105.Tallahassee, FL-Thomasville, GA', 30.685164, -84.127808],
  ['106.Lincoln & Hastings-Kearney, NE', 40.718119, -98.014526],
  ['107.Ft. Wayne, IN', 41.07521, -85.135803],
  ['108.Reno, NV', 39.523641, -119.809341],
  ['109.Youngstown, OH', 41.097982, -80.650978],
  ['110.Tyler-Longview(Lufkin & Nacogdoches), TX', 32.129105, -94.825745],
  ['111.Springfield-Holyoke, MA', 42.162385, -72.616882],
  ['112.Boise, ID', 43.602149, -116.21192],
  ['113.Sioux Falls (Mitchell), SD', 43.58238, -96.775818],
  ['114.Lansing, MI', 42.73037, -84.541168],
  ['115.Augusta, GA', 33.460088, -81.9841],
  ['116.Peoria-Bloomington, IL', 40.597271, -89.291382],
  ['117.Traverse City-Cadillac, MI', 44.488668, -85.487366],
  ['118.Montgomery-Selma, AL', 32.393878, -86.621704],
  ['119.Eugene, OR', 44.042193, -123.100433],
  ['120.Fargo-Valley City, ND', 46.860191, -97.404785],
  ['121.Santa Barbara-Santa Maria-San Luis Obispo, CA', 34.813803, -120.19043],
  ['122.Macon, GA', 32.841231, -83.648186],
  ['123.Lafayette, LA', 30.215762, -92.019081],
  ['124.Monterey-Salinas, CA', 36.628754, -121.764565],
  ['125.Bakersfield, CA', 35.367776, -119.014893],
  ['126.Yakima-Pasco-Richland-Kennewick, WA', 46.172223, -119.586181999999],
  ['127.La Crosse-Eau Claire, WI', 44.37884, -91.362305],
  ['128.Columbus, GA', 32.461109, -84.983368],
  ['129.Corpus Christi, TX', 27.798995, -97.395172],
  ['130.Chico-Redding, CA', 40.145289, -122.167969],
  ['131.Amarillo, TX', 35.200184, -101.837082],
  ['132.Rockford, IL', 42.262574, -89.082642],
  ['133.Columbus-Tupelo-West Point, MS', 33.829357, -88.632202],
  ['134.Wilmington, NC', 34.221739, -77.923279],
  ['135.Wausau-Rhinelander, WI', 45.301939, -89.527588],
  ['136.Monroe, LA-El Dorado, AR', 32.8842, -92.367554],
  ['137.Columbia-Jefferson City, MO', 38.76265, -92.25769],
  ['135.Topeka, KS', 39.043719, -95.682678],
  ['136.Duluth, MN-Superior, WI', 46.774671, -92.107315],
  ['140.Medford-Klamath Falls, OR', 42.326062, -122.360229],
  ['141.Beaumont-Port Arthur, TX', 29.985866, -94.038849],
  ['142.Palm Springs, CA', 33.800832, -116.541595],
  ['143.Lubbock, TX', 33.578015, -101.858368],
  ['144.Salisbury, MD', 38.368848, -75.584908],
  ['145.Wichita Falls, TX-Lawton, OK', 34.243595, -98.432007],
  ['146.Erie, PA', 42.122673, -80.080032],
  ['147.Albany, GA', 31.575611, -84.176216],
  ['148.Joplin, MO-Pittsburg, KS', 37.212832, -94.578552],
  ['149.Sioux City, IA', 42.488302, -96.405029],
  ['150.Anchorage, AK', 61.19886, -149.886475],
  ['151.Panama City, FL', 30.173625, -85.6707],
  ['152.Terre Haute, IN', 39.464294, -87.414093],
  ['153.Bangor, ME', 44.835909, -68.791924],
  ['154.Rochester, MN-Mason City, IA-Austin, MN', 43.608239, -92.955322],
  ['155.Bluefield-Beckley-Oak Hill, WV', 37.63381, -81.169739],
  ['156.Odessa-Midland, TX', 31.924193, -102.20993],
  ['158. Minot-Bismarck-Dickinson(Williston), ND', 47.546872, -102.304687],
  ['159.Wheeling, WV-Steubenville, OH', 40.225024, -80.661621],
  ['160.Gainesville, FL', 29.648675, -82.337723],
  ['161.Sherman, TX-Ada, OK', 34.268566, -96.632996],
  ['162.Idaho Falls-Pocatello, ID', 43.245203, -112.285767],
  ['163.Biloxi-Gulfport, MS', 30.372875, -89.01123],
  ['164.Yuma, AZ-El Centro, CA', 32.694866, -115.037842],
  ['165.Abilene-Sweetwater, TX', 32.477329, -100.085449],
  ['166.Missoula, MT', 46.873336, -114.001007],
  ['167.Hattiesburg-Laurel, MS', 31.5036289999999, -89.25293],
  ['168.Clarksburg-Weston, WV', 39.13006, -80.386963],
  ['169.Utica, NY', 43.099479, -75.244675],
  ['170.Billings, MT', 45.781412, -108.50544],
  ['171.Quincy, IL-Hannibal, MO-Keokuk, IA', 39.96028, -91.021729],
  ['172.Dothan, AL', 31.223959, -85.391922],
  ['173.Jackson, TN', 35.637767, -88.824463],
  ['174.Rapid City, SD', 44.080187, -103.230972],
  ['175.Elmira, NY', 42.094783, -76.812458],
  ['176.Lake Charles, LA', 30.212202, -93.204231],
  ['177.Watertown, NY', 43.975028, -75.910892],
  ['178.Harrisonburg, VA', 38.438262, -78.876343],
  ['179.Alexandria, LA', 31.292341, -92.466431],
  ['180.Marquette, MI', 46.539735, -87.40654],
  ['181.Jonesboro, AR', 35.82004, -90.682526],
  ['182.Bowling Green, KY', 36.971564, -86.44558],
  ['182.Bowling Green, KY', 36.970192, -86.444893],
  ['183.Charlottesville, VA', 38.037546, -78.489418],
  ['184.Grand Junction-Montrose, CO', 38.702659, -108.215332],
  ['185.Meridian, MS', 32.375902, -88.712883],
  ['186.Lima, OH', 40.742835, -84.113731],
  ['187.Greenwood-Greenville, MS', 33.642063, -90.005493],
  ['188.Laredo, TX', 27.553329, -99.489441],
  ['189.Lafayette, IN', 40.402778, -86.86306],
  ['190.Butte-Bozeman, MT', 45.79817, -111.862793],
  ['191.Great Falls, MT', 47.50607, -111.305923],
  ['192.Bend, OR', 44.059713, -121.312065],
  ['193.Parkersburg, WV', 39.263095, -81.542244],
  ['194.Twin Falls, ID', 42.56269, -114.460716],
  ['195.Eureka, CA', 40.785351, -124.161129],
  ['196.San Angelo, TX', 31.460883, -100.444565],
  ['197.Casper-Riverton, WY', 42.960443, -107.341919],
  ['198.Cheyenne, WY-Scottsbluff, NE', 41.520917, -104.260254],
  ['199.Mankato, MN', 44.166198, -93.99353],
  ['200.Ottumwa, IA-Kirksville, MO', 40.5931, -92.493896],
  ['201.St. Joseph, MO', 39.775297, -94.831238],
  ['202.Fairbanks, AK', 64.833174, -147.64595],
  ['203.Zanesville, OH', 39.952385, -82.00985],
  ['204.Presque Isle, ME', 46.692312, -67.993011],
  ['205.Victoria, TX', 28.8112879999999, -97.003784],
  ['206.Helena, MT', 46.590839, -112.02055],
  ['207.Juneau, AK', 58.361394, -134.571533],
  ['208.Alpena, MI', 45.072793, -83.436012],
  ['209.North Platte, NE', 41.132642, -100.772266],
  ['210.Glendive, MT', 47.110327, -104.70726]
];

// Info Window Content
var infoWindowContent = [
  ['1. New York, New York'],
  ['2. Los Angeles'],
  ['3. Chicago, IL'],
  ['4. Philadelphia, PA'],
  ['5. Dallas / Fort Worth'],
  ['6. San Francisco-Oakland-San Jose'],
  ['7. Boston, MA & Manchester , NH'],
  ['8. Atlanta, GA'],
  ['9. Washington, DC / Hagerstown, MD'],
  ['10. Houston, TX'],
  ['11. Detroit, MI'],
  ['12. Phoenix, AZ'],
  ['13. Tampa / Sarasota, FL'],
  ['14. Seattle / Tacoma, WA'],
  ['15. Minneapolis / St Paul, MN'],
  ['16. Miami / Fort Lauderdale, FL'],
  ['17. Cleveland / Akron, OH'],
  ['18. Denver, CO'],
  ['19. Orlando / Daytona Beach / Melbourne, FL'],
  ['20. Sacramento/Stockton/Modesto, CA'],
  ['21. St. Louis, MO'],
  ['22. Portland, OR'],
  ['23. Pittsburgh, PA'],
  ['24. Charlotte, NC'],
  ['25. Indianapolis, IN'],
  ['26. Baltimore, MD'],
  ['27. Raleigh-Durham (Fayetteville), NC'],
  ['28.San Diego, CA'],
  ['30.Hartford & New Haven, CT'],
  ['31.Kansas City, MO'],
  ['32.Columbus, OH'],
  ['33.Salt Lake City, UT'],
  ['34.Cincinnati, OH'],
  ['35.Milwaukee, WI'],
  ['38.West Palm Beach-Ft. Pierce, FL'],
  ['39.Grand Rapids-Kalamazoo-Battle Creek, MI'],
  ['40.Birmingham (Anniston and Tuscaloosa), AL'],
  ['36.Greenville-Spartanburg, SC-Asheville, NC-Anderson,SC'],
  ['41.Harrisburg-Lancaster-Lebanon-York, PA'],
  ['42.Las Vegas, NV'],
  ['43.Norfolk-Portsmouth-Newport News, VA'],
  ['44.Albuquerque-Santa Fe, NM'],
  ['45.Oklahoma City, OK'],
  ['47.Jacksonville, FL'],
  ['48.Memphis, TN'],
  ['49.Austin, TX'],
  ['50.Louisville, KY'],
  ['51.Buffalo, NY'],
  ['52.Providence, RI-New Bedford, MA'],
  ['53.New Orleans, LA'],
  ['54.Wilkes Barre-Scranton, PA'],
  ['55.Fresno-Visalia, CA'],
  ['56.Little Rock-Pine Bluff, AR'],
  ['57.Albany-Schenectady-Troy, NY'],
  ['58.Richmond-Petersburg, VA'],
  ['59.Knoxville, TN'],
  ['60.Mobile, AL-Pensacola (Ft. Walton Beach), FL'],
  ['61.Tulsa, OK'],
  ['62.Ft. Myers-Naples, Fl'],
  ['63.Lexington, KY'],
  ['64.Dayton, OH'],
  ['65.Charleston-Huntington, WV'],
  ['66.Flint-Saginaw-Bay City, MI'],
  ['67.Roanoke-Lynchburg, VA'],
  ['68.Tucson (Sierra Vista), AZ'],
  ['69.Wichita-Hutchinson, KS Plus'],
  ['70.Green Bay-Appleton, WI'],
  ['71.Des Moines-Ames, IA'],
  ['72.Honolulu, HI'],
  ['73.Toledo, OH'],
  ['74.Springfield, MO'],
  ['75.Spokane, WA'],
  ['76.Omaha, NE'],
  ['77.Portland-Auburn, ME'],
  ['78.Paducah, KY-Cape Girardeau, MO-Harrisburg, IL'],
  ['79.Columbia, SC'],
  ['80.Rochester, NY'],
  ['81.Syracuse, NY'],
  ['82.Huntsville-Decatur (Florence), AL'],
  ['83.Champaign & Springfield-Decatur, IL'],
  ['84.Shreveport, LA'],
  ['85.Madison, WI'],
  ['86.Chattanooga, TN'],
  ['87.Harlingen-Weslaco-Brownsville-McAllen, TX'],
  ['88.Cedar Rapids-Waterloo-Iowa City & Dubuque, IA'],
  ['89.South Bend-Elkhart, IN'],
  ['90.Jackson, MS'],
  ['91.Colorado Springs-Pueblo, CO'],
  ['92.Tri-Cities, TN-VA'],
  ['93.Burlington, VT-Plattsburgh, NY'],
  ['94.Waco-Temple-Bryan, TX'],
  ['95.Baton Rouge, LA'],
  ['96.Savannah, GA'],
  ['97.Davenport, IA-Rock Island-Moline, IL'],
  ['98.El Paso, TX'],
  ['99.Charleston, SC'],
  ['100.Ft. Smith-Fayetteville-Springdale-Rogers, AR'],
  ['101.Johnstown-Altoona, PA'],
  ['102.Evansville, IN'],
  ['103.Greenville-New Bern-Washington, NC'],
  ['104.Myrtle Beach-Florence, SC'],
  ['105.Tallahassee, FL-Thomasville, GA'],
  ['106.Lincoln & Hastings-Kearney, NE'],
  ['107.Ft. Wayne, IN'],
  ['108.Reno, NV'],
  ['109.Youngstown, OH'],
  ['110.Tyler-Longview(Lufkin & Nacogdoches), TX'],
  ['111.Springfield-Holyoke, MA'],
  ['112.Boise, ID'],
  ['113.Sioux Falls (Mitchell), SD'],
  ['114.Lansing, MI'],
  ['115.Augusta, GA'],
  ['116.Peoria-Bloomington, IL'],
  ['117.Traverse City-Cadillac, MI'],
  ['118.Montgomery-Selma, AL'],
  ['119.Eugene, OR'],
  ['120.Fargo-Valley City, ND'],
  ['121.Santa Barbara-Santa Maria-San Luis Obispo, CA'],
  ['122.Macon, GA'],
  ['123.Lafayette, LA'],
  ['124.Monterey-Salinas, CA'],
  ['125.Bakersfield, CA'],
  ['126.Yakima-Pasco-Richland-Kennewick, WA'],
  ['127.La Crosse-Eau Claire, WI'],
  ['128.Columbus, GA'],
  ['129.Corpus Christi, TX'],
  ['130.Chico-Redding, CA'],
  ['131.Amarillo, TX'],
  ['132.Rockford, IL'],
  ['133.Columbus-Tupelo-West Point, MS'],
  ['134.Wilmington, NC'],
  ['135.Wausau-Rhinelander, WI'],
  ['136.Monroe, LA-El Dorado, AR'],
  ['137.Columbia-Jefferson City, MO'],
  ['135.Topeka, KS'],
  ['136.Duluth, MN-Superior, WI'],
  ['140.Medford-Klamath Falls, OR'],
  ['141.Beaumont-Port Arthur, TX'],
  ['142.Palm Springs, CA'],
  ['143.Lubbock, TX'],
  ['144.Salisbury, MD'],
  ['145.Wichita Falls, TX-Lawton, OK'],
  ['146.Erie, PA'],
  ['147.Albany, GA'],
  ['148.Joplin, MO-Pittsburg, KS'],
  ['149.Sioux City, IA'],
  ['150.Anchorage, AK'],
  ['151.Panama City, FL'],
  ['152.Terre Haute, IN'],
  ['153.Bangor, ME'],
  ['154.Rochester, MN-Mason City, IA-Austin, MN'],
  ['155.Bluefield-Beckley-Oak Hill, WV'],
  ['156.Odessa-Midland, TX'],
  ['158. Minot-Bismarck-Dickinson(Williston), ND'],
  ['159.Wheeling, WV-Steubenville, OH'],
  ['160.Gainesville, FL'],
  ['161.Sherman, TX-Ada, OK'],
  ['162.Idaho Falls-Pocatello, ID'],
  ['163.Biloxi-Gulfport, MS'],
  ['164.Yuma, AZ-El Centro, CA'],
  ['165.Abilene-Sweetwater, TX'],
  ['166.Missoula, MT'],
  ['167.Hattiesburg-Laurel, MS'],
  ['168.Clarksburg-Weston, WV'],
  ['169.Utica, NY'],
  ['170.Billings, MT'],
  ['171.Quincy, IL-Hannibal, MO-Keokuk, IA'],
  ['172.Dothan, AL'],
  ['173.Jackson, TN'],
  ['174.Rapid City, SD'],
  ['175.Elmira, NY'],
  ['176.Lake Charles, LA'],
  ['177.Watertown, NY'],
  ['178.Harrisonburg, VA'],
  ['179.Alexandria, LA'],
  ['180.Marquette, MI'],
  ['181.Jonesboro, AR'],
  ['182.Bowling Green, KY'],
  ['182.Bowling Green, KY'],
  ['183.Charlottesville, VA'],
  ['184.Grand Junction-Montrose, CO'],
  ['185.Meridian, MS'],
  ['186.Lima, OH'],
  ['187.Greenwood-Greenville, MS'],
  ['188.Laredo, TX'],
  ['189.Lafayette, IN'],
  ['190.Butte-Bozeman, MT'],
  ['191.Great Falls, MT'],
  ['192.Bend, OR'],
  ['193.Parkersburg, WV'],
  ['194.Twin Falls, ID'],
  ['195.Eureka, CA'],
  ['196.San Angelo, TX'],
  ['197.Casper-Riverton, WY'],
  ['198.Cheyenne, WY-Scottsbluff, NE'],
  ['199.Mankato, MN'],
  ['200.Ottumwa, IA-Kirksville, MO'],
  ['201.St. Joseph, MO'],
  ['202.Fairbanks, AK'],
  ['203.Zanesville, OH'],
  ['204.Presque Isle, ME'],
  ['205.Victoria, TX'],
  ['206.Helena, MT'],
  ['207.Juneau, AK'],
  ['208.Alpena, MI'],
  ['209.North Platte, NE'],
  ['210.Glendive, MT']
];
&#13;
<script async defer src="https://maps.googleapis.com/maps/api/js?callback=initMap">
</script>

<div id="map" style="height:500px; outline:1px red solid"></div>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

要初始化地图(如果您不打算致电.fitBounds),您需要设置所需的“mapOptions”:缩放和居中。

一个选项是将其添加到循环中:

if (markers[i][0] == '45.Oklahoma City, OK') {
    map.setCenter(marker.getPosition());
    map.setZoom(10);
}

代码段

function initMap() {
    var map;
    var bounds = new google.maps.LatLngBounds();
    var mapOptions = {
      mapTypeId: 'roadmap'
    };

    // Display a map on the page
    map = new google.maps.Map(document.getElementById("map"), mapOptions);
    map.setTilt(45);

    // Display multiple markers on a map
    var infoWindow = new google.maps.InfoWindow(),
      marker, i;

    // Loop through our array of markers & place each one on the map  
    for (i = 0; i < markers.length; i++) {
      var position = new google.maps.LatLng(markers[i][1], markers[i][2]);
      bounds.extend(position);
      marker = new google.maps.Marker({
        position: position,
        map: map,
        title: markers[i][0]
      });

      // Allow each marker to have an info window    
      google.maps.event.addListener(marker, 'click', (function(marker, i) {
        return function() {
          infoWindow.setContent(infoWindowContent[i][0]);
          infoWindow.open(map, marker);
        }
      })(marker, i));

      // Automatically center the map fitting all markers on the screen
      // map.fitBounds(bounds);
      if (markers[i][0] == '45.Oklahoma City, OK') {
        map.setCenter(marker.getPosition());
        map.setZoom(10);
      }
    }
  }
  // Multiple Markers
var markers = [
  ['1. New York, New York', 40.747257, -73.953094],
  ['2. Los Angeles', 34.040143, -118.243103],
  ['3. Chicago, IL', 41.869561, -87.622833],
  ['4. Philadelphia, PA', 39.943436, -75.164337],
  ['5. Dallas / Fort Worth', 32.7688, -96.855469],
  ['6. San Francisco-Oakland-San Jose', 37.773429, -122.418938],
  ['7. Boston, MA & Manchester , NH', 42.352455, -71.058197],
  ['8. Atlanta, GA', 33.754031, -84.388733],
  ['9. Washington, DC / Hagerstown, MD', 38.892636, -77.023087],
  ['10. Houston, TX', 29.756032, -95.362701],
  ['11. Detroit, MI', 42.324032, -83.044968],
  ['12. Phoenix, AZ', 33.417687, -112.07428],
  ['13. Tampa / Sarasota, FL', 27.974998, -82.450333],
  ['14. Seattle / Tacoma, WA', 47.614958, -122.347183],
  ['15. Minneapolis / St Paul, MN', 44.971599, -93.264313],
  ['16. Miami / Fort Lauderdale, FL', 25.770832, -80.190239],
  ['17. Cleveland / Akron, OH', 41.493664, -81.692963],
  ['18. Denver, CO', 39.751017, -104.988098],
  ['19. Orlando / Daytona Beach / Melbourne, FL', 28.537481, -81.366119],
  ['20. Sacramento/Stockton/Modesto, CA', 38.568569, -121.486816],
  ['21. St. Louis, MO', 38.622235, -90.197754],
  ['22. Portland, OR', 45.525592, -122.678833],
  ['23. Pittsburgh, PA', 40.438586, -80.013428],
  ['24. Charlotte, NC', 35.209722, -80.90332],
  ['25. Indianapolis, IN', 39.774769, -86.176758],
  ['26. Baltimore, MD', 39.283294, -76.629639],
  ['27. Raleigh-Durham (Fayetteville), NC', 35.038992, -78.892822],
  ['28.San Diego, CA', 32.694866, -117.180176],
  ['30.Hartford & New Haven, CT', 41.537366, -72.743225],
  ['31.Kansas City, MO', 39.085304, -94.584045],
  ['32.Columbus, OH', 39.962386, -83.000336],
  ['33.Salt Lake City, UT', 40.768582, -111.887512],
  ['34.Cincinnati, OH', 39.094897, -84.518509],
  ['35.Milwaukee, WI', 43.038783, -87.912598],
  ['38.West Palm Beach-Ft. Pierce, FL', 26.725987, -80.117798],
  ['39.Grand Rapids-Kalamazoo-Battle Creek, MI', 42.912183, -85.671387],
  ['40.Birmingham (Anniston and Tuscaloosa), AL', 33.507049, -86.812592],
  ['36.Greenville-Spartanburg, SC-Asheville, NC-Anderson,SC', 34.813803, -82.419434],
  ['41.Harrisburg-Lancaster-Lebanon-York, PA', 40.191463, -76.830139],
  ['42.Las Vegas, NV', 36.151182, -115.169678],
  ['43.Norfolk-Portsmouth-Newport News, VA', 36.840065, -76.330261],
  ['44.Albuquerque-Santa Fe, NM', 35.424868, -106.292725],
  ['45.Oklahoma City, OK', 35.483038, -97.481689],
  ['47.Jacksonville, FL', 30.315988, -81.657257],
  ['48.Memphis, TN', 35.136756, -90.049438],
  ['49.Austin, TX', 30.264998, -97.742615],
  ['50.Louisville, KY', 38.254358, -85.749664],
  ['51.Buffalo, NY', 42.885776, -78.877029],
  ['52.Providence, RI-New Bedford, MA', 41.647775, -70.96344],
  ['53.New Orleans, LA', 29.916852, -90.087891],
  ['54.Wilkes Barre-Scranton, PA', 41.248644, -75.864716],
  ['55.Fresno-Visalia, CA', 36.558188, -119.602661],
  ['56.Little Rock-Pine Bluff, AR', 34.730327, -92.28653],
  ['57.Albany-Schenectady-Troy, NY', 42.74197, -73.817139],
  ['58.Richmond-Petersburg, VA', 37.205722, -77.389755],
  ['59.Knoxville, TN', 35.96189, -83.923874],
  ['60.Mobile, AL-Pensacola (Ft. Walton Beach), FL', 30.465247, -87.203979],
  ['61.Tulsa, OK', 36.132329, -95.971069],
  ['62.Ft. Myers-Naples, Fl', 26.346345, -81.824799],
  ['63.Lexington, KY', 38.048226, -84.499969],
  ['64.Dayton, OH', 39.762631, -84.205399],
  ['65.Charleston-Huntington, WV', 38.408406, -82.062378],
  ['66.Flint-Saginaw-Bay City, MI', 43.276205, -83.84079],
  ['67.Roanoke-Lynchburg, VA', 37.32212, -79.656372],
  ['68.Tucson (Sierra Vista), AZ', 32.222096, -110.939941],
  ['69.Wichita-Hutchinson, KS Plus', 37.870517, -97.662964],
  ['70.Green Bay-Appleton, WI', 44.364115, -88.177643],
  ['71.Des Moines-Ames, IA', 41.73033, -93.383789],
  ['72.Honolulu, HI', 21.294493, -157.82135],
  ['73.Toledo, OH', 41.65188, -83.577461],
  ['74.Springfield, MO', 37.195878, -93.284912],
  ['75.Spokane, WA', 47.65105, -117.409514999999],
  ['76.Omaha, NE', 41.258194, -95.942917],
  ['77.Portland-Auburn, ME', 43.91768, -70.032349],
  ['78.Paducah, KY-Cape Girardeau, MO-Harrisburg, IL', 37.049697, -88.608856],
  ['79.Columbia, SC', 33.994612, -81.033783],
  ['80.Rochester, NY', 43.151098, -77.617035],
  ['81.Syracuse, NY', 43.049823, -76.146584],
  ['82.Huntsville-Decatur (Florence), AL', 34.661452, -86.779633],
  ['83.Champaign & Springfield-Decatur, IL', 39.901309, -88.901367],
  ['84.Shreveport, LA', 32.512078, -93.747025],
  ['85.Madison, WI', 43.059356, -89.399185],
  ['86.Chattanooga, TN', 35.061477, -85.254593],
  ['87.Harlingen-Weslaco-Brownsville-McAllen, TX', 26.160369, -97.987061],
  ['88.Cedar Rapids-Waterloo-Iowa City & Dubuque, IA', 41.820455, -91.601257],
  ['89.South Bend-Elkhart, IN', 41.689322, -86.10878],
  ['90.Jackson, MS', 32.310349, -90.178528],
  ['91.Colorado Springs-Pueblo, CO', 38.823126, -104.81781],
  ['92.Tri-Cities, TN-VA', 36.487557, -82.353516],
  ['93.Burlington, VT-Plattsburgh, NY', 44.594379, -73.309021],
  ['94.Waco-Temple-Bryan, TX', 31.1564079999999, -96.734619],
  ['95.Baton Rouge, LA', 30.462879, -91.129532],
  ['96.Savannah, GA', 32.076757, -81.095581],
  ['97.Davenport, IA-Rock Island-Moline, IL', 41.482862, -90.502625],
  ['98.El Paso, TX', 31.751525, -106.486359],
  ['99.Charleston, SC', 32.79247, -79.942017],
  ['100.Ft. Smith-Fayetteville-Springdale-Rogers, AR', 36.075742, -94.177551],
  ['101.Johnstown-Altoona, PA', 40.504402, -78.399811],
  ['102.Evansville, IN', 37.975327, -87.541122],
  ['103.Greenville-New Bern-Washington, NC', 35.431582, -77.176208],
  ['104.Myrtle Beach-Florence, SC', 34.020795, -79.373474],
  ['105.Tallahassee, FL-Thomasville, GA', 30.685164, -84.127808],
  ['106.Lincoln & Hastings-Kearney, NE', 40.718119, -98.014526],
  ['107.Ft. Wayne, IN', 41.07521, -85.135803],
  ['108.Reno, NV', 39.523641, -119.809341],
  ['109.Youngstown, OH', 41.097982, -80.650978],
  ['110.Tyler-Longview(Lufkin & Nacogdoches), TX', 32.129105, -94.825745],
  ['111.Springfield-Holyoke, MA', 42.162385, -72.616882],
  ['112.Boise, ID', 43.602149, -116.21192],
  ['113.Sioux Falls (Mitchell), SD', 43.58238, -96.775818],
  ['114.Lansing, MI', 42.73037, -84.541168],
  ['115.Augusta, GA', 33.460088, -81.9841],
  ['116.Peoria-Bloomington, IL', 40.597271, -89.291382],
  ['117.Traverse City-Cadillac, MI', 44.488668, -85.487366],
  ['118.Montgomery-Selma, AL', 32.393878, -86.621704],
  ['119.Eugene, OR', 44.042193, -123.100433],
  ['120.Fargo-Valley City, ND', 46.860191, -97.404785],
  ['121.Santa Barbara-Santa Maria-San Luis Obispo, CA', 34.813803, -120.19043],
  ['122.Macon, GA', 32.841231, -83.648186],
  ['123.Lafayette, LA', 30.215762, -92.019081],
  ['124.Monterey-Salinas, CA', 36.628754, -121.764565],
  ['125.Bakersfield, CA', 35.367776, -119.014893],
  ['126.Yakima-Pasco-Richland-Kennewick, WA', 46.172223, -119.586181999999],
  ['127.La Crosse-Eau Claire, WI', 44.37884, -91.362305],
  ['128.Columbus, GA', 32.461109, -84.983368],
  ['129.Corpus Christi, TX', 27.798995, -97.395172],
  ['130.Chico-Redding, CA', 40.145289, -122.167969],
  ['131.Amarillo, TX', 35.200184, -101.837082],
  ['132.Rockford, IL', 42.262574, -89.082642],
  ['133.Columbus-Tupelo-West Point, MS', 33.829357, -88.632202],
  ['134.Wilmington, NC', 34.221739, -77.923279],
  ['135.Wausau-Rhinelander, WI', 45.301939, -89.527588],
  ['136.Monroe, LA-El Dorado, AR', 32.8842, -92.367554],
  ['137.Columbia-Jefferson City, MO', 38.76265, -92.25769],
  ['135.Topeka, KS', 39.043719, -95.682678],
  ['136.Duluth, MN-Superior, WI', 46.774671, -92.107315],
  ['140.Medford-Klamath Falls, OR', 42.326062, -122.360229],
  ['141.Beaumont-Port Arthur, TX', 29.985866, -94.038849],
  ['142.Palm Springs, CA', 33.800832, -116.541595],
  ['143.Lubbock, TX', 33.578015, -101.858368],
  ['144.Salisbury, MD', 38.368848, -75.584908],
  ['145.Wichita Falls, TX-Lawton, OK', 34.243595, -98.432007],
  ['146.Erie, PA', 42.122673, -80.080032],
  ['147.Albany, GA', 31.575611, -84.176216],
  ['148.Joplin, MO-Pittsburg, KS', 37.212832, -94.578552],
  ['149.Sioux City, IA', 42.488302, -96.405029],
  ['150.Anchorage, AK', 61.19886, -149.886475],
  ['151.Panama City, FL', 30.173625, -85.6707],
  ['152.Terre Haute, IN', 39.464294, -87.414093],
  ['153.Bangor, ME', 44.835909, -68.791924],
  ['154.Rochester, MN-Mason City, IA-Austin, MN', 43.608239, -92.955322],
  ['155.Bluefield-Beckley-Oak Hill, WV', 37.63381, -81.169739],
  ['156.Odessa-Midland, TX', 31.924193, -102.20993],
  ['158. Minot-Bismarck-Dickinson(Williston), ND', 47.546872, -102.304687],
  ['159.Wheeling, WV-Steubenville, OH', 40.225024, -80.661621],
  ['160.Gainesville, FL', 29.648675, -82.337723],
  ['161.Sherman, TX-Ada, OK', 34.268566, -96.632996],
  ['162.Idaho Falls-Pocatello, ID', 43.245203, -112.285767],
  ['163.Biloxi-Gulfport, MS', 30.372875, -89.01123],
  ['164.Yuma, AZ-El Centro, CA', 32.694866, -115.037842],
  ['165.Abilene-Sweetwater, TX', 32.477329, -100.085449],
  ['166.Missoula, MT', 46.873336, -114.001007],
  ['167.Hattiesburg-Laurel, MS', 31.5036289999999, -89.25293],
  ['168.Clarksburg-Weston, WV', 39.13006, -80.386963],
  ['169.Utica, NY', 43.099479, -75.244675],
  ['170.Billings, MT', 45.781412, -108.50544],
  ['171.Quincy, IL-Hannibal, MO-Keokuk, IA', 39.96028, -91.021729],
  ['172.Dothan, AL', 31.223959, -85.391922],
  ['173.Jackson, TN', 35.637767, -88.824463],
  ['174.Rapid City, SD', 44.080187, -103.230972],
  ['175.Elmira, NY', 42.094783, -76.812458],
  ['176.Lake Charles, LA', 30.212202, -93.204231],
  ['177.Watertown, NY', 43.975028, -75.910892],
  ['178.Harrisonburg, VA', 38.438262, -78.876343],
  ['179.Alexandria, LA', 31.292341, -92.466431],
  ['180.Marquette, MI', 46.539735, -87.40654],
  ['181.Jonesboro, AR', 35.82004, -90.682526],
  ['182.Bowling Green, KY', 36.971564, -86.44558],
  ['182.Bowling Green, KY', 36.970192, -86.444893],
  ['183.Charlottesville, VA', 38.037546, -78.489418],
  ['184.Grand Junction-Montrose, CO', 38.702659, -108.215332],
  ['185.Meridian, MS', 32.375902, -88.712883],
  ['186.Lima, OH', 40.742835, -84.113731],
  ['187.Greenwood-Greenville, MS', 33.642063, -90.005493],
  ['188.Laredo, TX', 27.553329, -99.489441],
  ['189.Lafayette, IN', 40.402778, -86.86306],
  ['190.Butte-Bozeman, MT', 45.79817, -111.862793],
  ['191.Great Falls, MT', 47.50607, -111.305923],
  ['192.Bend, OR', 44.059713, -121.312065],
  ['193.Parkersburg, WV', 39.263095, -81.542244],
  ['194.Twin Falls, ID', 42.56269, -114.460716],
  ['195.Eureka, CA', 40.785351, -124.161129],
  ['196.San Angelo, TX', 31.460883, -100.444565],
  ['197.Casper-Riverton, WY', 42.960443, -107.341919],
  ['198.Cheyenne, WY-Scottsbluff, NE', 41.520917, -104.260254],
  ['199.Mankato, MN', 44.166198, -93.99353],
  ['200.Ottumwa, IA-Kirksville, MO', 40.5931, -92.493896],
  ['201.St. Joseph, MO', 39.775297, -94.831238],
  ['202.Fairbanks, AK', 64.833174, -147.64595],
  ['203.Zanesville, OH', 39.952385, -82.00985],
  ['204.Presque Isle, ME', 46.692312, -67.993011],
  ['205.Victoria, TX', 28.8112879999999, -97.003784],
  ['206.Helena, MT', 46.590839, -112.02055],
  ['207.Juneau, AK', 58.361394, -134.571533],
  ['208.Alpena, MI', 45.072793, -83.436012],
  ['209.North Platte, NE', 41.132642, -100.772266],
  ['210.Glendive, MT', 47.110327, -104.70726]
];

// Info Window Content
var infoWindowContent = [
  ['1. New York, New York'],
  ['2. Los Angeles'],
  ['3. Chicago, IL'],
  ['4. Philadelphia, PA'],
  ['5. Dallas / Fort Worth'],
  ['6. San Francisco-Oakland-San Jose'],
  ['7. Boston, MA & Manchester , NH'],
  ['8. Atlanta, GA'],
  ['9. Washington, DC / Hagerstown, MD'],
  ['10. Houston, TX'],
  ['11. Detroit, MI'],
  ['12. Phoenix, AZ'],
  ['13. Tampa / Sarasota, FL'],
  ['14. Seattle / Tacoma, WA'],
  ['15. Minneapolis / St Paul, MN'],
  ['16. Miami / Fort Lauderdale, FL'],
  ['17. Cleveland / Akron, OH'],
  ['18. Denver, CO'],
  ['19. Orlando / Daytona Beach / Melbourne, FL'],
  ['20. Sacramento/Stockton/Modesto, CA'],
  ['21. St. Louis, MO'],
  ['22. Portland, OR'],
  ['23. Pittsburgh, PA'],
  ['24. Charlotte, NC'],
  ['25. Indianapolis, IN'],
  ['26. Baltimore, MD'],
  ['27. Raleigh-Durham (Fayetteville), NC'],
  ['28.San Diego, CA'],
  ['30.Hartford & New Haven, CT'],
  ['31.Kansas City, MO'],
  ['32.Columbus, OH'],
  ['33.Salt Lake City, UT'],
  ['34.Cincinnati, OH'],
  ['35.Milwaukee, WI'],
  ['38.West Palm Beach-Ft. Pierce, FL'],
  ['39.Grand Rapids-Kalamazoo-Battle Creek, MI'],
  ['40.Birmingham (Anniston and Tuscaloosa), AL'],
  ['36.Greenville-Spartanburg, SC-Asheville, NC-Anderson,SC'],
  ['41.Harrisburg-Lancaster-Lebanon-York, PA'],
  ['42.Las Vegas, NV'],
  ['43.Norfolk-Portsmouth-Newport News, VA'],
  ['44.Albuquerque-Santa Fe, NM'],
  ['45.Oklahoma City, OK'],
  ['47.Jacksonville, FL'],
  ['48.Memphis, TN'],
  ['49.Austin, TX'],
  ['50.Louisville, KY'],
  ['51.Buffalo, NY'],
  ['52.Providence, RI-New Bedford, MA'],
  ['53.New Orleans, LA'],
  ['54.Wilkes Barre-Scranton, PA'],
  ['55.Fresno-Visalia, CA'],
  ['56.Little Rock-Pine Bluff, AR'],
  ['57.Albany-Schenectady-Troy, NY'],
  ['58.Richmond-Petersburg, VA'],
  ['59.Knoxville, TN'],
  ['60.Mobile, AL-Pensacola (Ft. Walton Beach), FL'],
  ['61.Tulsa, OK'],
  ['62.Ft. Myers-Naples, Fl'],
  ['63.Lexington, KY'],
  ['64.Dayton, OH'],
  ['65.Charleston-Huntington, WV'],
  ['66.Flint-Saginaw-Bay City, MI'],
  ['67.Roanoke-Lynchburg, VA'],
  ['68.Tucson (Sierra Vista), AZ'],
  ['69.Wichita-Hutchinson, KS Plus'],
  ['70.Green Bay-Appleton, WI'],
  ['71.Des Moines-Ames, IA'],
  ['72.Honolulu, HI'],
  ['73.Toledo, OH'],
  ['74.Springfield, MO'],
  ['75.Spokane, WA'],
  ['76.Omaha, NE'],
  ['77.Portland-Auburn, ME'],
  ['78.Paducah, KY-Cape Girardeau, MO-Harrisburg, IL'],
  ['79.Columbia, SC'],
  ['80.Rochester, NY'],
  ['81.Syracuse, NY'],
  ['82.Huntsville-Decatur (Florence), AL'],
  ['83.Champaign & Springfield-Decatur, IL'],
  ['84.Shreveport, LA'],
  ['85.Madison, WI'],
  ['86.Chattanooga, TN'],
  ['87.Harlingen-Weslaco-Brownsville-McAllen, TX'],
  ['88.Cedar Rapids-Waterloo-Iowa City & Dubuque, IA'],
  ['89.South Bend-Elkhart, IN'],
  ['90.Jackson, MS'],
  ['91.Colorado Springs-Pueblo, CO'],
  ['92.Tri-Cities, TN-VA'],
  ['93.Burlington, VT-Plattsburgh, NY'],
  ['94.Waco-Temple-Bryan, TX'],
  ['95.Baton Rouge, LA'],
  ['96.Savannah, GA'],
  ['97.Davenport, IA-Rock Island-Moline, IL'],
  ['98.El Paso, TX'],
  ['99.Charleston, SC'],
  ['100.Ft. Smith-Fayetteville-Springdale-Rogers, AR'],
  ['101.Johnstown-Altoona, PA'],
  ['102.Evansville, IN'],
  ['103.Greenville-New Bern-Washington, NC'],
  ['104.Myrtle Beach-Florence, SC'],
  ['105.Tallahassee, FL-Thomasville, GA'],
  ['106.Lincoln & Hastings-Kearney, NE'],
  ['107.Ft. Wayne, IN'],
  ['108.Reno, NV'],
  ['109.Youngstown, OH'],
  ['110.Tyler-Longview(Lufkin & Nacogdoches), TX'],
  ['111.Springfield-Holyoke, MA'],
  ['112.Boise, ID'],
  ['113.Sioux Falls (Mitchell), SD'],
  ['114.Lansing, MI'],
  ['115.Augusta, GA'],
  ['116.Peoria-Bloomington, IL'],
  ['117.Traverse City-Cadillac, MI'],
  ['118.Montgomery-Selma, AL'],
  ['119.Eugene, OR'],
  ['120.Fargo-Valley City, ND'],
  ['121.Santa Barbara-Santa Maria-San Luis Obispo, CA'],
  ['122.Macon, GA'],
  ['123.Lafayette, LA'],
  ['124.Monterey-Salinas, CA'],
  ['125.Bakersfield, CA'],
  ['126.Yakima-Pasco-Richland-Kennewick, WA'],
  ['127.La Crosse-Eau Claire, WI'],
  ['128.Columbus, GA'],
  ['129.Corpus Christi, TX'],
  ['130.Chico-Redding, CA'],
  ['131.Amarillo, TX'],
  ['132.Rockford, IL'],
  ['133.Columbus-Tupelo-West Point, MS'],
  ['134.Wilmington, NC'],
  ['135.Wausau-Rhinelander, WI'],
  ['136.Monroe, LA-El Dorado, AR'],
  ['137.Columbia-Jefferson City, MO'],
  ['135.Topeka, KS'],
  ['136.Duluth, MN-Superior, WI'],
  ['140.Medford-Klamath Falls, OR'],
  ['141.Beaumont-Port Arthur, TX'],
  ['142.Palm Springs, CA'],
  ['143.Lubbock, TX'],
  ['144.Salisbury, MD'],
  ['145.Wichita Falls, TX-Lawton, OK'],
  ['146.Erie, PA'],
  ['147.Albany, GA'],
  ['148.Joplin, MO-Pittsburg, KS'],
  ['149.Sioux City, IA'],
  ['150.Anchorage, AK'],
  ['151.Panama City, FL'],
  ['152.Terre Haute, IN'],
  ['153.Bangor, ME'],
  ['154.Rochester, MN-Mason City, IA-Austin, MN'],
  ['155.Bluefield-Beckley-Oak Hill, WV'],
  ['156.Odessa-Midland, TX'],
  ['158. Minot-Bismarck-Dickinson(Williston), ND'],
  ['159.Wheeling, WV-Steubenville, OH'],
  ['160.Gainesville, FL'],
  ['161.Sherman, TX-Ada, OK'],
  ['162.Idaho Falls-Pocatello, ID'],
  ['163.Biloxi-Gulfport, MS'],
  ['164.Yuma, AZ-El Centro, CA'],
  ['165.Abilene-Sweetwater, TX'],
  ['166.Missoula, MT'],
  ['167.Hattiesburg-Laurel, MS'],
  ['168.Clarksburg-Weston, WV'],
  ['169.Utica, NY'],
  ['170.Billings, MT'],
  ['171.Quincy, IL-Hannibal, MO-Keokuk, IA'],
  ['172.Dothan, AL'],
  ['173.Jackson, TN'],
  ['174.Rapid City, SD'],
  ['175.Elmira, NY'],
  ['176.Lake Charles, LA'],
  ['177.Watertown, NY'],
  ['178.Harrisonburg, VA'],
  ['179.Alexandria, LA'],
  ['180.Marquette, MI'],
  ['181.Jonesboro, AR'],
  ['182.Bowling Green, KY'],
  ['182.Bowling Green, KY'],
  ['183.Charlottesville, VA'],
  ['184.Grand Junction-Montrose, CO'],
  ['185.Meridian, MS'],
  ['186.Lima, OH'],
  ['187.Greenwood-Greenville, MS'],
  ['188.Laredo, TX'],
  ['189.Lafayette, IN'],
  ['190.Butte-Bozeman, MT'],
  ['191.Great Falls, MT'],
  ['192.Bend, OR'],
  ['193.Parkersburg, WV'],
  ['194.Twin Falls, ID'],
  ['195.Eureka, CA'],
  ['196.San Angelo, TX'],
  ['197.Casper-Riverton, WY'],
  ['198.Cheyenne, WY-Scottsbluff, NE'],
  ['199.Mankato, MN'],
  ['200.Ottumwa, IA-Kirksville, MO'],
  ['201.St. Joseph, MO'],
  ['202.Fairbanks, AK'],
  ['203.Zanesville, OH'],
  ['204.Presque Isle, ME'],
  ['205.Victoria, TX'],
  ['206.Helena, MT'],
  ['207.Juneau, AK'],
  ['208.Alpena, MI'],
  ['209.North Platte, NE'],
  ['210.Glendive, MT']
];
<script async defer src="https://maps.googleapis.com/maps/api/js?callback=initMap">
</script>

<div id="map" style="height:500px; outline:1px red solid"></div>