Hello,
Pls can anyone give me an example how to make this:
I want to create a application that has this:
1) A list of GPS Coordinates of places i give + the name of that place, that i want to display them on the map.
2) Is it possible to display those coordinates on the map with a .png picture i have on my (files folder, is this possible?, or just in a url)
3) I want to be able to get my location where i am right now, and see the rest of the places distance from me.
And if possible to make the appz not needed to use the internet only for the maps. to be able to see those coordinates in an offline manner.
i searched the forums, got this example, but i'm not too deep into programming , so if anyone could guide me with some nice code examples, i would really appreciate it, thanks in advance.
this is the part of the code i found on the forum and was messing around.
but it's already too late (03:56am) and i have to go to work at 08:00am, if some nice guru's of this forum could help me out, it would be really great
Joel
Pls can anyone give me an example how to make this:
I want to create a application that has this:
1) A list of GPS Coordinates of places i give + the name of that place, that i want to display them on the map.
2) Is it possible to display those coordinates on the map with a .png picture i have on my (files folder, is this possible?, or just in a url)
3) I want to be able to get my location where i am right now, and see the rest of the places distance from me.
And if possible to make the appz not needed to use the internet only for the maps. to be able to see those coordinates in an offline manner.
i searched the forums, got this example, but i'm not too deep into programming , so if anyone could guide me with some nice code examples, i would really appreciate it, thanks in advance.
this is the part of the code i found on the forum and was messing around.
but it's already too late (03:56am) and i have to go to work at 08:00am, if some nice guru's of this forum could help me out, it would be really great
Joel
B4X:
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim MapWebView As WebView
Dim ScaleLat, ScaleLong As Float
Dim PosLat, PosLong As List
End Sub
Sub Activity_Create(FirstTime As Boolean)
PosLat.Initialize
PosLong.Initialize
' ***** Localização da Pamela no mapa *****
PosLat.Add(37.134062)
PosLong.Add(-8.5445)
' ***** Localização de teste ao pé da Pamela no mapa 02 *****
PosLat.Add(37.130829)
PosLong.Add(-8.547463)
PosLat.Add(37.136646)
PosLong.Add(-8.551583)
PosLat.Add(37.142325)
PosLong.Add(-8.543773)
PosLat.Add(37.143967)
PosLong.Add(-8.563685)
PosLat.Add(37.12029)
PosLong.Add(-8.567033)
MapWebView.Initialize("")
Activity.AddView(MapWebView,0,0,100%x,100%y)
ShowMap(38.712572, -9.135189, 5, True, True, True, "TOP_LEFT", True, PosLat, PosLong, True, True, "#ff0000", 0.5, 3)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub ShowMap(CenterLat As Float, CenterLong As Float, Zoom As Int, MapTypeControl As Boolean, DispZoomControl As Boolean, DispScaleControl As Boolean, ScaleControlPosition As String, DispMarkerCenter As Boolean, MarkerLat As List, MarkerLong As List, DispMarkers As Boolean, DispPolyline As Boolean, PolyLineColor As String, PolyLineOpacity As Float, PolyLineWidth As Int)
' CenterLat = latitude of map center in degrees
' CenterLong = longitude of map center in degrees
' Zoom = zomm index 0 - 21
' MapTypeControl = true displays the map type control
' DispZoomControl = true displays the zoom control otherwise false
' ScaleControl = true displays the zoom control otherwise false
' ScaleControlPosition = position of the scale control TOP_LEFT, TOP_CENTER, TOP_RIGHT, LEFT_CENTER, RIGHT_CENTER, BOTTOM_LEFT, BOTTOM_CENTER, BOTTOM_RIGHT
' DispMarkerCenter = true sets a marker on the center of the map
' MarkerLat = List of lat positions of the markers
' MarkerLong = List of long positions of the markers
' DipsMarkers = true displays the markers
' DispPolyline = true displays a polyline with the markers as vertices
' PolyLineColor = polyline color hexadecimal #ff0000 = red #00ff00 = green #0000ff = blue
' PolyLineOpacity = polyline opacity 0.0 transparent 1.0 full opaque
' PolyLineWidth = polyline width in pixels
Dim HtmlCode As String
Dim i, j As Int
HtmlCode = "<!DOCTYPE html><html><head><meta name='viewport' content='initial-scale=1.0, user-scalable=no' /><style type='text/css'> html { height: 100% } body { height: 100%; margin: 0px; padding: 0px }#map_canvas { height: 100% }</style><script type='text/javascript' src='http://maps.google.com/maps/api/js?sensor=true'></script><script type='text/javascript'> function initialize() {var latlng = new google.maps.LatLng(" & CenterLat & "," & CenterLong & "); var myOptions = { zoom: "&Zoom&", center: latlng, disableDefaultUI: true, zoomControl: "& DispZoomControl & ", scaleControl: "& DispScaleControl & ", scaleControlOptions: {position: google.maps.ControlPosition." & ScaleControlPosition & "}, mapTypeControl: "& MapTypeControl& ", mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById('map_canvas'), myOptions)"
' displays a marker on the map center
If DispMarkerCenter = True Then
HtmlCode = HtmlCode & "; var markerc = new google.maps.Marker({ position: new google.maps.LatLng(" & CenterLat & "," & CenterLong & "),map: map, title: '',clickable: false,icon: 'http://www.google.com/mapfiles/arrow.png' })"
End If
' displays markers on the map
If MarkerLat.Size>0 AND DispMarkers = True Then
j = MarkerLat.Size - 1
If j = 0 Then
HtmlCode = HtmlCode & "; var marker" & i & " = new google.maps.Marker({ position: new google.maps.LatLng(" & MarkerLat.Get(i) & "," & MarkerLong.Get(i) & "),map: map, title: 'Test" & i & "',clickable: true, draggable: false, icon: 'http://img42.imageshack.us/img42/2521/penelopeicon.png' })"
' HtmlCode = HtmlCode & "; google.maps.event.addListener(marker" & i & ", 'click', function() {alert('Marker1')} )"
Else If j = 1 Then
HtmlCode = HtmlCode & "; var marker" & i & " = new google.maps.Marker({ position: new google.maps.LatLng(" & MarkerLat.Get(i) & "," & MarkerLong.Get(i) & "),map: map, title: 'Test" & i & "',clickable: true, draggable: false, icon: 'http://www.google.com/mapfiles/marker_green.png' })"
' HtmlCode = HtmlCode & "; google.maps.event.addListener(marker" & i & ", 'click', function() {map.set_center(marker" & i & ")} )"
HtmlCode = HtmlCode & "; var marker" & i & " = new google.maps.Marker({ position: new google.maps.LatLng(" & MarkerLat.Get(i) & "," & MarkerLong.Get(i) & "),map: map, title: 'Test" & i & "',clickable: true, draggable: false, icon: 'http://www.google.com/mapfiles/marker.png' })"
' HtmlCode = HtmlCode & "; google.maps.event.addListener(marker" & i & ", 'click', function() {map.set_center(marker" & i & ")} )"
Else
HtmlCode = HtmlCode & "; var marker0 = new google.maps.Marker({ position: new google.maps.LatLng(" & MarkerLat.Get(i) & "," & MarkerLong.Get(i) & "),map: map, title: 'Test0',clickable: true, draggable: false, icon: 'http://www.google.com/mapfiles/marker_greenA.png' })"
' HtmlCode = HtmlCode & "; google.maps.event.addListener(marker0, 'click', function() {alert('Marker0')} )"
For i = 1 To j - 1 ' diplays the markers
HtmlCode = HtmlCode & "; var marker" & i & " = new google.maps.Marker({ position: new google.maps.LatLng(" & MarkerLat.Get(i) & "," & MarkerLong.Get(i) & "),map: map, title: 'Test" & i & "',clickable: true, draggable: false, icon: 'http://www.google.com/mapfiles/marker_orange" & Chr(i + 65) & ".png' })"
' HtmlCode = HtmlCode & "; google.maps.event.addListener(marker" & i & ", 'click', function() {map.set_center(marker" & i & ")} )"
Next
HtmlCode = HtmlCode & "; var marker" & (j) & " = new google.maps.Marker({ position: new google.maps.LatLng(" & MarkerLat.Get(j) & "," & MarkerLong.Get(j) & "),map: map, title: 'Test" & j & "',clickable: true, draggable: false, icon: 'http://www.google.com/mapfiles/marker" & Chr(j + 65) & ".png' })"
' HtmlCode = HtmlCode & "; google.maps.event.addListener(marker" & i & ", 'click', function() {map.set_center(marker" & i & ")} )"
End If
' ' displays a polyline between the markers
' If DispPolyLine = True AND j > 0 Then
' HtmlCode = HtmlCode & "; var points = ["
' HtmlCode = HtmlCode & " new google.maps.LatLng(" & MarkerLat.Get(0) & "," & MarkerLong.Get(0) & ")"
' For i=1 To j
' HtmlCode = HtmlCode & ", new google.maps.LatLng(" & MarkerLat.Get(i) & "," & MarkerLong.Get(i) & ")"
' Next
' HtmlCode = HtmlCode & "] "
' HtmlCode = HtmlCode & "; var polyline = new google.maps.Polyline({path: points, strokeColor: '" & PolyLineColor & "', strokeOpacity: " & PolyLineOpacity & ", strokeWeight: " & PolyLineWidth & "})"
' HtmlCode = HtmlCode & "; polyline.setMap(map)"
' End If
End If
HtmlCode = HtmlCode & "; }</script></head><body onload='initialize()'> <div id='map_canvas' style='width:100%; height:100%'></div></body></html>"
MapWebView.LoadHtml(HtmlCode)
End Sub