NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

I am trying to plot 200 locations on map using open street map layer. I have stored all addresses in array. I am running the loop but my code doesn't plot more than 9 locations on map.

My code is:

<body background-color="green">

<script>
map = new OpenLayers.Map('mapdiv');
map.addLayer(new OpenLayers.Layer.OSM());

epsg4326 =  new OpenLayers.Projection('EPSG:4326'); //WGS 1984 projection
projectTo = map.getProjectionObject();

var lonLat = new OpenLayers.LonLat( 90.417931,36.778259).transform(epsg4326, projectTo);

var zoom=4;
map.setCenter (lonLat, zoom);

var vectorLayer = new OpenLayers.Layer.Vector('Overlay');

var geocoder = new google.maps.Geocoder();

var address = ['address1','address2'------'address200']; for (i = 0; i< 200; i++) { geocoder.geocode( { 'address': address[i]}, function(results, status) {

if (status == google.maps.GeocoderStatus.OK) {

var feature = new OpenLayers.Feature.Vector( new OpenLayers.Geometry.Point( results[0].geometry.location.lng(),results[0].geometry.location.lat()).transform(epsg4326, projectTo),{description:'This is the value of
the description attribute'} , {externalGraphic: 'http://leafletjs.com/dist/images/marker-icon-2x.png', graphicHeight: 25, graphicWidth: 21, graphicXOffset:-12,graphicYOffset:-25 } );

vectorLayer.addFeatures(feature);
map.addLayer(vectorLayer);

} }); } map.addLayer(vectorLayer);

</script>

asked 21 Jul '15, 22:44

Ashnav's gravatar image

Ashnav
11223
accept rate: 0%

closed 21 Jul '15, 23:52

SK53's gravatar image

SK53 ♦
28.1k48268433

The question has been closed for the following reason "Question seems to be about Google geo-coding with OpenLayers" by SK53 21 Jul '15, 23:52

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×362
×122

question asked: 21 Jul '15, 22:44

question was seen: 3,784 times

last updated: 21 Jul '15, 23:52

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum