Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Status Updates

View All Updates

- - - - -

creating an app for android phone


This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1 jamesb


    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 04 February 2015 - 12:33 PM


New to programming and having a problem with an app i am creating.  I am trying to use gmaps and  I would like to be able to have the user select from a list the starting and ending points, then get driving directions.  Here is what i have so far.  The problem i am having is that the map does not move on the device.  It allows me to select starting and ending points but then does not give directions.  hope someone can point me in the right direction

<meta name="viewport" content="initial-scale=1.0, user-scalable=yes">
<meta charset="utf-8">

<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script><script src="https://maps.gstatic.com/maps-api-v3/api/js/19/9/main.js"></script><script src="https://maps.gstatic.com/maps-api-v3/api/js/19/7a/main.js"></script>
	var directionsDisplay;
	var directionsService = new google.maps.DirectionsService();

	function initialize() {
		directionsDisplay = new google.maps.DirectionsRenderer();
		var Auckland = new google.maps.LatLng(-37.008222, 174.785025);
		var mapOptions = {
			zoom: 7,
			center: new google.maps.LatLng(-37.008222, 174.785025)
		var map = new google.maps.Map(document.getElementById('map-canvas'),
		var control = document.getElementById('control');
		control.style.display = 'block';

	function calcRoute() {
		var start = document.getElementById('start').value;
		var end = document.getElementById('end').value;
		var request = {
			travelMode: google.maps.TravelMode.DRIVING
		directionsService.route(request, function(response, status) {
			if (status == google.maps.DirectionsStatus.OK) {

	google.maps.event.addDomListener(window, 'load', initialize);

<div id="control" style="height: 70px; overflow: hidden; top: 5px; margin-left: 0px; z-index: 5; border: 1px solid rgb(153, 153, 153); display: block; position: relative; background-color: rgb(5, 5, 5);">&nbsp;<select id="start" onchange="calcRoute();"><option value="Auckland Airport Ray Emery Drive">Start
	</option><option value="41 towey st,oamaru">Pen-y-bryn lodge
	</option><option value="224 Rhodes Rd,	Christchurch">Otahuna Lodge
	</option><option value="11075 West Coast Hwy 73, Cass,Christchurch">Grasmere Lodge
	</option><option value="Western Lake road,Wellington">Wharekauhau Lodge
	&nbsp;<select id="end" onchange="calcRoute();"><option value="Auckland Airport
																  Ray Emery Drive">Destination
	</option><option value="41 towey st,oamaru">Pen-y-bryn lodge
	</option><option value="Bay of Many Coves,Marlborough,Bay Of Many Coves">Bay of Many Coves
	</option><option value="297 Cape Saunders Road,RD2 Portobello,Dunedin ">Kaimata Retreat
	</option><option value="494 Wanaka-Mount Aspiring Road,Glendhu Bay">Whare Kea Lodge
	</option><option value="Rapid 4191, Glenorchy">Blanket Bay
	</option><option value="569 Glenorchy-Queenstown Road,Queenstown">Matakauri Lodge

<div id="map-canvas" style="position: relative; height: 300px; border: 1px solid;"><div style="overflow: hidden; width: 320px; height: 303px;"><img src="https://maps.googleapis.com/maps/api/js/StaticMapService.GetMapImage?1m2&amp;1i32133&amp;2i19863&amp;2e1&amp;3u7&amp;4m2&amp;1u320&amp;2u303&amp;5m5&amp;1e0&amp;5sen-US&amp;6sus&amp;10b1&amp;12b1&amp;token=99558" style="width: 320px; height: 303px;"></div></div>
<div id="directions-panel" style="position: relative; top 350px; border: 1px solid; color: rgb(3, 3, 3); background-color: rgb(247, 247, 247);"></div>

#2 BlackRabbit


    CodeCall Legend

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3871 posts

Posted 14 February 2015 - 03:27 PM

Welcome aboard JamesB.


MoveCamera is the method to move in the map, you should call it implementing the listeners, so you can react to users' request of moving the map center/location.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download