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">

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 } );


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


asked 21 Jul '15, 22:44

Ashnav's gravatar image

accept rate: 0%

closed 21 Jul '15, 23:52

SK53's gravatar image

SK53 ♦

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



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:


question asked: 21 Jul '15, 22:44

question was seen: 2,325 times

last updated: 21 Jul '15, 23:52

powered by OSQA