Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am developing an app using OpenTripPlanner.

It creates an OpenLayer map in map.js. I want to access this map in index.html so I can set it's center.

Kindly help me out.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

i dont think opentripplanner uses openlayers so i have checked it and it uses leaflet so you have to use following method for centering your map.(you can put it anywhere after your map.js is loaded)

_container div#map2.leaflet-container

map.panTo(new L.LatLng(lon, lat));

i hope it helps you...

share|improve this answer

In index.html :

<head>
    <script src="map.js"></script>
    <script src="myscript.js"></script>
</head>

In myscript.js

mapVariable.setCenter(new OpenLayers.LonLat( yourLon, yourLat) , theZoomLevel );
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.