google maps administration.

If you have questions about using mojoPortal, you can post them here.

You may want to first review our site administration documentation to see if your question is answered there.

This thread is closed to new posts. You must sign in to post in the forums.
4/24/2012 8:40:57 AM
Gravatar
Total Posts 192

google maps administration.

hi.

how can I specify a startup location in google maps feature in forms of latitude and longitude (or geotag) or anything?

I just need a sample, or how to.

google maps is not good enough for iran locations, it's hard to find locations just by names.

(i tried searching to find samples for using latitude and longitude with showgmap javascript function. but couldn't find anything.

what version of api current feature is based on? currently google maps javascript api v3 is available. is it based on this version? I guess this version doesn't require an api key...)

4/24/2012 9:23:25 AM
Gravatar
Total Posts 192

Re: google maps administration.

found the solution.

I had first used the numbers in the bottom of the screen of the google earth. but it wasn't working as expected.

the correct location needs to be in decimal format.

to find out the correct location in decimal format, these sites can be used:

http://universimmedia.pagesperso-orange.fr/geo/loc.htm

http://itouchmap.com/latlong.html

then the latitude and longitude need to be entered in the location setting, simply separated by a comma.

4/24/2012 12:20:32 PM
Gravatar
Total Posts 18439

Re: google maps administration.

That is a good tip! I did not know you could use long and lat separated by a comma there.

Note that it does use the newer api unless you enable local search and if there is an api key available for the old api. Lox=cal search is not implemented in the new api so we fall back to the old one if that is enabled and there is an api key.

Best,

Joe

4/25/2012 8:50:15 AM
Gravatar
Total Posts 192

Re: google maps administration.

hi Joe.

currently there is a problem with how the map feature works, when specifying latitude and longitude.

it always tries to geocode the location.

so if there is no road or a known place, near the specified location, it will show the nearest road, or city or ...

there should be an option that will prevent it from geocoding the location, if it's specified as lat and long.

4/25/2012 9:37:54 AM
Gravatar
Total Posts 192

Re: google maps administration.

hi Joe.

I've done a very quick fix to clientscripts/google/mojogmaputils3.js

I changed showgmap to this:

 

function showGMap(divMap, address, enableMapType, enableZoom, showInfoWindow, enableLocalSearch, mapType, zoomLevel)
/* Note: Local Search is deprecated. Not removed yet, although the enableLocalSearch flag will have no effect here */
{

if (address.match(/^\d\d\.\d+,\d\d\.\d+$/))
{
var commaindex = address.indexOf(',', 0)
latitude = address.substring(0,commaindex)
longitude = address.substring(commaindex + 1,address.length+1)
var ll = new google.maps.LatLng(latitude, longitude);
var mapOpts = {zoomControl: enableZoom,
zoom: zoomLevel,
center: ll,
mapTypeControl: enableMapType,
mapTypeId: mapTypeTrans(mapType)};
var map = new google.maps.Map(divMap, mapOpts);
var marker = new google.maps.Marker({map: map, position: ll, title:address});
if (showInfoWindow) {
var infoWindow = new google.maps.InfoWindow({content: address, position:ll});
infoWindow.open(map,marker);
}
}
else
{
if (geocoder == null)
{
initializemojomaputils();
}

if (geocoder)
{
geocoder.geocode({'address': address}, function(result,status) {
if (status==google.maps.GeocoderStatus.OK) {
var ll = new google.maps.LatLng();
var mapOpts = {zoomControl: enableZoom,
zoom: zoomLevel,
center: result[0].geometry.location,
mapTypeControl: enableMapType,
mapTypeId: mapTypeTrans(mapType)};
var map = new google.maps.Map(divMap, mapOpts);
//map.setMapTypeId(mapTypeTrans(mapType));
var marker = new google.maps.Marker({map: map, position: result[0].geometry.location, title:address});
if (showInfoWindow) {
var infoWindow = new google.maps.InfoWindow({content: address, position:result[0].geometry.location});
infoWindow.open(map,marker);
}
} else {
divMap.innerHTML = 'location not found';
}
});
} else {
divMap.innerHTML = 'service not available';
}
}
}       

 

it works for me.

but I'm not a professional javascript coder. don't know how compatible this is in different browsers. but I tried to do my best.

if you think it's good enough (for a while), please commit it.

thanks.

4/25/2012 9:51:31 AM
Gravatar
Total Posts 18439

Re: google maps administration.

Sorry but I don't think that is a correct solution. Location is meant for being geocoded and it may contain commas. Currently I can put:

Charlotte, NC

as the location and it will work but your solutiion will break it.

That is why I was surprised when you previously said it works by entering a long,lat in the location field.

I've added a to do item in my project tracker to add support for long/lat as an alternative to location, but I think we need to add new fields in settings for long and lat instead of trying to use the location field. Then if log/lat is specified in settings we will use that instead of location.

I willl get to this when I have time.

Best,

Joe

4/25/2012 10:08:31 AM
Gravatar
Total Posts 192

Re: google maps administration.

no Joe, it won't break that.

I've used a regular expression which is:

/^\d\d\.\d+,\d\d\.\d+$/

two digits, a dot, some digits, then two digits, a dot and again some digits.

so it's completely impossible.

(oh, I just remembered that I need to include '-' too, lat and long can be negative)

beside that, the current implementation still works with latitude and longitude separated by a comma, but it will fall to the nearest known location on map.

my problem with current implementation was that I was trying to show places in jungles and mountains, and it was showing the nearest roads.

 

and of course providing latitude and longitude in separate fields is the correct solution.

4/25/2012 10:17:54 AM
Gravatar
Total Posts 18439

Re: google maps administration.

Ok, I missed that part, just do some testing to make sure it works with all variations that you can think of and then send me the updated js.

Best,

Joe

You must sign in to post in the forums. This thread is closed to new posts.