简体   繁体   中英

Placing markers via latitude and longitude with JavaScript and Google's geocode API

I'm trying to run a Java application that is supposed to take in several hundred (at least) zip/postal codes and placing markers on a given map using JavaScript. I've got the map out, and I'm able to place markers on it, but once I hit past 20 markers I start getting the OVER_QUERY_LIMIT error.

I've done my homework and discovered that this is due to my client-side geocoding, and tried to look up methods to do server-side geocoding but haven't been very successful. I'm now attempting to store all the latitude-longitude pairs within a given database. Every time a new postal/zip code is entered into the dataset, my application should the geocode the given postal/zip code and search up the given lat-long pair before placing it into the database.

Every time I view the map, the application will attempt to pull the lat-long pairs out of the database (which will be stored as String values) and place markers on the map. The problem is, I'm not sure how to do that. Can markers be placed solely using latitude/longitude pairs? If so, how can this be done?

Just to clarify, the application is a Java one, using Servlets to handle the data and .jsp pages to print the maps.

Something like

var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
    var myOptions = {
      zoom: 4,
      center: myLatlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

    var marker = new google.maps.Marker({
        position: myLatlng, 
        map: map,
        title:"Hello World!"
    });   

from http://code.google.com/apis/maps/documentation/javascript/examples/marker-simple.html ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM