For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub
- This topic has 5 replies, 2 voices, and was last updated 13 years, 8 months ago by
support-octavio.
-
AuthorPosts
-
Visal VengMemberHi guys,
So iv managed to get my current location running with marker etc.. but how do I get the infor window to pop up with the street address like google map??
cheers
vee
November 14, 2012 at 3:48 pm #332316
support-octavioMemberHi Visal,
Please see this example on our Map Developers Guide:
https://www.genuitec.com/mobile/docs/usingMaps/usingMaps.html#add_markers
November 15, 2012 at 4:59 am #332332
Visal VengMemberThanks octavio
So iv got my current location working & when i tap the marker it pops up with window but it only says “Position 1 info”…?? no adress details
here is my custom.js so far:
function showLocation(gmap, pos) {
gmap.setCenter(pos);//add marker
var marker = new google.maps.Marker({
position: pos,
map: gmap,
animation: google.maps.Animation.DROP,
title: “Current Location”,
clickable: true
});
var infowindow1 = new google.maps.InfoWindow({
content: “Position 1 info”
});
google.maps.event.addListener(marker, ‘click’, function() {
infowindow1.open(gmap,marker);
});}
in title area im i suppost to add a line of code so it will show my location address etc..?
sorry if this sounds stupid. im new to code
cheers
vee
November 15, 2012 at 4:52 pm #332360
support-octavioMemberHi Visal,
Next Google Maps Javascript API Doc should be helpful for you: https://developers.google.com/maps/documentation/javascript/geocoding#ReverseGeocoding
November 16, 2012 at 12:01 am #332376
Visal VengMemberthanks octavio,
here is my custom.js so far:
* Called when document is loaded.
*/
phoneui.documentReadyHandler = function() {
var init = function() {
$(‘[id$=map1]’).gmapready(function(gmap) {
navigator.geolocation.getCurrentPosition(
function(geoPosition) {
var mapPos = new google.maps.LatLng(geoPosition.coords.latitude,
geoPosition.coords.longitude);
showLocation(gmap,mapPos)
},
function() {
alert(‘Unable to find current position’);
});
});
};if (“PhoneGap” in window) {
document.addEventListener(“deviceready”, init, false);
} else {
init();
}
}function showLocation(gmap, pos) {
gmap.setCenter(pos);//add marker
var marker = new google.maps.Marker({
position: pos,
map: gmap,
zoom: 10,
animation: google.maps.Animation.DROP,
title: “Current Location”,
clickable: true
});var geocoder;
var map;
var infowindow = new google.maps.InfoWindow();
var marker;
function initialize() {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(geoPosition.coords.latitude,
geoPosition.coords.longitude);
var mapOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById(“map_canvas”), mapOptions);
}function codeLatLng() {
var input = document.getElementById(“latlng”).value;
var latlngStr = input.split(“,”,2);
var lat = parseFloat(latlngStr[0]);
var lng = parseFloat(latlngStr[1]);
var latlng = new google.maps.LatLng(lat, lng);
geocoder.geocode({‘latLng’: latlng}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[1]) {
map.setZoom(11);
marker = new google.maps.Marker({
position: latlng,
map: gmap
});
infowindow.setContent(results[1].formatted_address);
infowindow.open(map, marker);
}
} else {
alert(“Geocoder failed due to: ” + status);
}
});
}​Im not getting anything, what am i doing wrong?
cheers
vee
November 20, 2012 at 6:42 pm #332524
support-octavioMemberHi Visal,
I’ve reviewed your code, it seems that you did a copy/paste and as you see, the result is a nogo. Will coordinate with Wayne to help you on this request.
-
AuthorPosts
