Can't get the map to show using the example and wonder if I can enter an IP to look up?

3 views
Skip to first unread message

Bill

unread,
Aug 19, 2009, 9:50:07 AM8/19/09
to Loki API
I'm thinking of using Loki in admin of my webstore so that I from my
order pages can get a location for the purchasing customer. I have the
IP number of the customers but can't get the map to show and can't
understand how to input the IP number properly. I use a CS-Cart store
with Smarty classes and have entered this Loki code into my order
pages:

{literal}
<script type="text/javascript" src="http://loki.com/plugin/files/
loki.js"></script>
<script type="text/javascript">
//<![CDATA[

var map;
function init() {
// Setup the GMap instance
map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(42.364632, -71.058368), 13);

// and kick off the Loki request
requestLocation();
}

function requestLocation() {

var loki = new LokiAPI();
loki.onSuccess = function(location) {
// Populate form input fields
document.getElementById("address").value = location.house_number+'
'+location.street;
document.getElementById("city").value = location.city;
document.getElementById("region_code").value =
location.region_code;
document.getElementById("postal_code").value =
location.postal_code;

// Reset the center of the map and place a new marker
var point = new GLatLng(parseFloat(location.latitude), parseFloat
(location.longitude));
map.setCenter(point, 13);
var marker = new GMarker(point);
map.addOverlay(marker);
marker.openInfoWindowHtml('<strong>Your location</strong><br/
>'+location.latitude+', '+location.longitude+'');
};
loki.onFailure = function(error, msg){
alert('An error has been encountered ('+error+'). '+msg);
};
loki.setKey("beta");

// Here we want the entire location object returned -- lat/lon and
full reverse geocode
loki.requestLocation(true,loki.FULL_STREET_ADDRESS_LOOKUP);
}

window.onload = init;
//]]>
</script>

{/literal}

Can anyone please point me in the right direction?
Thank you!
Bill

Solenko

unread,
Aug 19, 2009, 10:05:34 AM8/19/09
to Loki API
You can't set ip address which will be used for IP Geolocation. Plugin
works with your current IP address only.
Take a look on maxmind ip geolocation for your project.
Reply all
Reply to author
Forward
0 new messages