cancel
Showing results for 
Search instead for 
Did you mean: 

sap.ui.vbm.GeoMap- pointing to position based on searched location

former_member197827
Participant
0 Kudos

Hi All,

I am developg an applicatiinon using  sap.ui.vbm.GeoCircle control. Here I am providing an input option with suggestion enabled, which I can use to search the predefined places(GeoCircles) that are coming from the backend server through oData service. So please help me to locate the GeoCircle Based on the input provided.


Thanks and Regards,

Sagar Patil

Accepted Solutions (0)

Answers (2)

Answers (2)

ralf_rath
Explorer
0 Kudos

which browser do you use? Some inhibit the download of images (= map tiles) from a different server or some ask you if it's ok.

Do you see a map if you don't zoom-in?

Have you changed the default map provider settings?

Thanks

former_member197827
Participant
0 Kudos

Hi Ralf,

I am using chrome Version 45.0.2454.85 m.

I can see the map when I don't zoom-in and I can see the map if I zoom-in using mouse also. But if I try to zoom in,using following code

  1. var geoMap=this.byId("vbi"); 
  2. geoMap.zoomToGeoPosition("-73.985428,40.748817,5"); 


map disappears. I have not changed the default map provider settings. How and where do I need to change it??

former_member182119
Active Participant
0 Kudos

Hi,

I guess it is just a little misstake. Function zoomToGeoPosition takes three parameters fLon. fLat, and iLod. In your example you provide one parameter, which is a string composed out of the three expected ones. Just omit rthe quotes and it may work.

Best regards,

Uwe

Former Member
0 Kudos

Hi Sagar,

use semi-colon(;) instead of comma(,) in zoomToGeoPosition function

I hope it will work

saivellanki
Active Contributor
0 Kudos

Hi Sagar,

Not sure, whether this is what you're expecting / not?  http://embed.plnkr.co/zW3GL0tBbA95qPJ9LzLL/preview

Input control is placed underneath the map, start typing '1'/'2'/'7'/'9' and suggestion list opens, select a value then the position of Geo circle will be set to the position selected in input.


Regards,

Sai Vellanki.

former_member197827
Participant
0 Kudos

Hi Sai,

Thanks for your reply. But this is not what I am looking for.Let us say we have plotted some 10 GeoCircles on map and I have an input field with suggestion which is used to key in Geo Locations.Assume I have entered GeoLocation of Paris which is one among  those 10 GeoLocations.Now Map should zoom(optional) and point to the Paris Location just like we search for the places in google map and it will point to the searched location.

Thanks and Regards,

Sagar M Patil

saivellanki
Active Contributor
0 Kudos

Hi Sagar,

Did you try using zoomToGeoPosition / zoomToArea methods?

Check this link where you can find list of samples using zoomTo - Visual Business UI5 Tests Index

Regards,

Sai Vellanki.

Former Member
0 Kudos

Hi Sagar Patil,

you can follow these steps:

1 pass your location or city in this URL, and use an appropriate google api key

var geoloc = new sap.ui.model.json.JSONModel("https://maps.googleapis.com/maps/api/geocode/json?address="+location+","+city+"&KEY%20=%20%22<your google key>%22");

2. Now get latitude and longitude using this code

var lat = geoloc.oData.results[0].geometry.location.lat;

var lng = geoloc.oData.results[0].geometry.location.lng;

3. Now pass this lat and lng to your GeoCircle or set this as maps initialPosition and initialZoom between 10-14.

It should work fine.

additionally, you can use spots instead of geocircle

Regards,

Vishnu

former_member197827
Participant
0 Kudos

Hi sai,

I tried using zoomToGeoPosition but not working as expected. map is idssappearing and only I am able to see the geocircles.

former_member197827
Participant
0 Kudos

Hi Vishnu,

Thanks for your reply.

Till second point it's ok as I am able to get the latitude and longitude of reqired location.Can you please explain the 3rd point ??

Here is my approach which is not working. I am using below mentioned code in selectionChange event of combobox.

var geoMap=this.byId("vbi");

geoMap.zoomToGeoPosition("-73.985428;40.748817;5")

once this piece of code gets executed, map is vanishing and I can see only GeoCircles.

I tried following.This is also not working.

<vbm:GeoCircles  id="GeoCircle"

         items="{oModel>/CirclesGeoDist}"

     click="onClickItem"

     contextMenu="onContextMenuItem" >

  <vbm:GeoCircle

     position="{oModel>A}"

     tooltip="{oModel>D}"

     radius="{oModel>E}"

     color="{oModel>B}"

     colorBorder="{oModel>C}"

     slices="{oModel>G}"

     click="onClickGeoCircle"

     contextMenu="onContextMenuGeoCircle"/>

  </vbm:GeoCircles>

var geoCircle=this.byId("GeoCircle");

  geoCircle.setPosition("-73.985428;40.748817;5")

saivellanki
Active Contributor
0 Kudos

Hi Sagar,

It should be like this I think. Instead of ';' use ',' and check -


var geoMap=this.byId("vbi");

geoMap.zoomToGeoPosition("-73.985428,40.748817,5");

Regards,

Sai Vellanki.

Former Member
0 Kudos

Hi Sagar Patil,

I found the solution.

You are not calling the geocircle, you are calling its parent control.

There are 2 ways:

first method) instead of geoCircle.setPosition("-73.985428;40.748817;5")

use geoCircle.getItems()[0].setPosition("-73.985428;40.748817;5");

(or)

second method) set an ID to vbm:GeoCircle

in View,

    <vbm:GeoCircle

     id="circleposition"

     position="{oModel>A}"

     tooltip="{oModel>D}"

     radius="{oModel>E}"

     color="{oModel>B}"

     colorBorder="{oModel>C}"

     slices="{oModel>G}"

     click="onClickGeoCircle"

     contextMenu="onContextMenuGeoCircle"/>

in controller,

  var geoCircle=this.byId("circleposition");

   geoCircle.setPosition("-73.985428;40.748817;5");

I hope, this will solve your problem.

Additionally, instead of position, use  your longitude and latitude which you have fetched from that google map api key

lng+";"+ lat +";0"

With Regards,

Vishnu

former_member197827
Participant
0 Kudos

Hi Sai,

This is also not working.

former_member197827
Participant
0 Kudos

HI Vishnu,

Still problem persists... Map is not rerendering

Thanks and regards,

Sagar M Patil

Former Member
0 Kudos

include the sap.ui.vbm library in the index's bootstrap

and send me the screenshot of the console windows where you can see the error message